There are n employees working in company "X" (let's number them from 1 to n for convenience). Initially the employees didn't have any relationships among each other. On each of m next days one of the following events took place:  either employee y became the boss of employee x (at that, employee x didn't have a boss before);  or employee x gets a packet of documents and signs them; then he gives the packet to his boss. The boss signs the documents and gives them to his boss and so on (the last person to sign the documents sends them to the archive);  or comes a request of type "determine whether employee x signs certain documents". 

Your task is to write a program that will, given the events, answer the queries of the described type. At that, it is guaranteed that throughout the whole working time the company didn't have cyclic dependencies.


-----Input-----

The first line contains two integers n and m (1 ≤ n, m ≤ 10^5) — the number of employees and the number of events. 

Each of the next m lines contains the description of one event (the events are given in the chronological order). The first number of the line determines the type of event t (1 ≤ t ≤ 3).   If t = 1, then next follow two integers x and y (1 ≤ x, y ≤ n) — numbers of the company employees. It is guaranteed that employee x doesn't have the boss currently.  If t = 2, then next follow integer x (1 ≤ x ≤ n) — the number of the employee who got a document packet.  If t = 3, then next follow two integers x and i (1 ≤ x ≤ n; 1 ≤ i ≤ [number of packets that have already been given]) — the employee and the number of the document packet for which you need to find out information. The document packets are numbered started from 1 in the chronological order. 

It is guaranteed that the input has at least one query of the third type.


-----Output-----

For each query of the third type print "YES" if the employee signed the document package and "NO" otherwise. Print all the words without the quotes.


-----Examples-----
Input
4 9
1 4 3
2 4
3 3 1
1 2 3
2 2
3 1 2
1 3 1
2 2
3 1 3

Output
YES
NO
YES

Difficulty: HARD

Solutions:
(n, m) = map(int, input().split())
ev = [tuple(map(int, input().split())) for _ in range(m)]
g = [[] for _ in range(n + 1)]
qry = [[] for _ in range(m + 1)]
roots = set(range(1, n + 1))
qcnt = 0
for e in ev:
	if e[0] == 1:
		g[e[2]].append(e[1])
		roots.remove(e[1])
	elif e[0] == 3:
		qry[e[2]].append((qcnt, e[1]))
		qcnt += 1
(tin, tout) = ([0] * (n + 1), [0] * (n + 1))
st = [(u, 0) for u in roots]
time = 0
while st:
	(u, w) = st.pop()
	if w:
		tout[u] = time
		continue
	time += 1
	tin[u] = time
	st.append((u, 1))
	for v in g[u]:
		st.append((v, 0))
p = list(range(n + 1))

def find(x):
	if x != p[x]:
		p[x] = find(p[x])
	return p[x]
pcnt = 0
ans = [None] * qcnt
for e in ev:
	if e[0] == 1:
		p[find(e[1])] = find(e[2])
	elif e[0] == 2:
		pcnt += 1
		for (qid, x) in qry[pcnt]:
			ans[qid] = 'YES' if find(e[1]) == find(x) and tin[x] <= tin[e[1]] <= tout[x] else 'NO'
print(*ans, sep='\n')