from collections import defaultdict

N, Q = map(int, input().split())
T, A, B = zip(*(map(int, input().split()) for _ in range(Q)))

follows = defaultdict(lambda: set())
for i in range(Q):
    if T[i] == 1:
        follows[A[i]].add(B[i])
    elif T[i] == 2:
        if B[i] in follows[A[i]]:
            follows[A[i]].remove(B[i])
    elif T[i] == 3:
        if B[i] in follows[A[i]] and A[i] in follows[B[i]]:
            print("Yes")
        else:
            print("No")
