#include <bits/stdc++.h>
#define task "disconnect"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 1e5 + 3;
int n, m, st[N], ed[N], bit[N], neu, dep[N], pa[17][N];
vi g[N];
void upd(int p, int v)
{
for (; p <= n; p += p & (-p)) bit[p] += v;
}
int query(int p)
{
int res = 0;
for (; p; p -= p & (-p)) res += bit[p];
return res;
}
void dfs(int u, int p)
{
st[u] = ++neu;
dep[u] = dep[p] + 1;
pa[0][u] = p;
rep(k, 1, 16) pa[k][u] = pa[k - 1][pa[k - 1][u]];
for (int v : g[u]) if (v != p)
dfs(v, u);
ed[u] = neu;
}
int lca(int x, int y)
{
if (dep[x] < dep[y]) swap(x, y);
Rep(k, 16, 0) if (dep[pa[k][x]] >= dep[y]) x = pa[k][x];
if (x == y) return x;
Rep(k, 16, 0) if (pa[k][x] != pa[k][y]) x = pa[k][x], y = pa[k][y];
return pa[0][x];
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
freopen("disconnect.in", "r", stdin);
freopen("disconnect.out", "w", stdout);
cin >> n >> m;
rep(i, 2, n)
{
int u, v;
cin >> u >> v;
g[u].eb(v);
g[v].eb(u);
}
dfs(1, 0);
//PR(eul, 1, neu);
int vv = 0;
while (m--)
{
int t, x, y, u, v;
cin >> t >> x >> y;
u = x ^ vv;
v = y ^ vv;
int z = lca(u, v);
if (t == 1)
{
if (pa[0][v] == u) swap(u, v);
upd(st[u], 1);
upd(ed[u] + 1, -1);
} else
{
int du = query(st[u]);
int dv = query(st[v]);
int dz = query(st[z]);
if (du + dv - 2 * dz > 0)
{
cout << "NO\n";
vv = v;
} else
{
cout << "YES\n";
vv = u;
}
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CgojZGVmaW5lIHRhc2sgImRpc2Nvbm5lY3QiCiNkZWZpbmUgQUxMKHYpICh2KS5iZWdpbigpLCAodikuZW5kKCkKI2RlZmluZSByZXAoaSwgbCwgcikgZm9yIChpbnQgaSA9IChsKTsgaSA8PSAocik7ICsraSkKI2RlZmluZSBSZXAoaSwgciwgbCkgZm9yIChpbnQgaSA9IChyKTsgaSA+PSAobCk7IC0taSkKI2RlZmluZSBEQihYKSB7IGNlcnIgPDwgI1ggPDwgIiA9ICIgPDwgKFgpIDw8ICdcbic7IH0KI2RlZmluZSBEQjEoQSwgXykgeyBjZXJyIDw8ICNBIDw8ICJbIiA8PCBfIDw8ICJdID0gIiA8PCAoQVtfXSkgPDwgJ1xuJzsgfQojZGVmaW5lIERCMihBLCBfLCBfXykgeyBjZXJyIDw8ICNBIDw8ICJbIiA8PCBfIDw8ICJdWyIgPDwgX18gPDwgIl0gPSAiIDw8IChBW19dW19fXSkgPDwgJ1xuJzsgfQojZGVmaW5lIERCMyhBLCBfLCBfXywgX19fKSB7IGNlcnIgPDwgI0EgPDwgIlsiIDw8IF8gPDwgIl1bI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+PiBtOwogICAgcmVwKGksIDIsIG4pCiAgICB7CiAgICAgICAgaW50IHUsIHY7CiAgICAgICAgY2luID4+IHUgPj4gdjsKICAgICAgICBnW3VdLmViKHYpOwogICAgICAgIGdbdl0uZWIodSk7CiAgICB9CiAgICBkZnMoMSwgMCk7CiAgICAvL1BSKGV1bCwgMSwgbmV1KTsKICAgIGludCB2diA9IDA7CiAgICB3aGlsZSAobS0tKQogICAgewogICAgICAgIGludCB0LCB4LCB5LCB1LCB2OwogICAgICAgIGNpbiA+PiB0ID4+IHggPj4geTsKICAgICAgICB1ID0geCBeIHZ2OwogICAgICAgIHYgPSB5IF4gdnY7CiAgICAgICAgaW50IHogPSBsY2EodSwgdik7CiAgICAgICAgaWYgKHQgPT0gMSkKICAgICAgICB7CiAgICAgICAgICAgIGlmIChwYVswXVt2XSA9PSB1KSBzd2FwKHUsIHYpOwogICAgICAgICAgICB1cGQoc3RbdV0sIDEpOwogICAgICAgICAgICB1cGQoZWRbdV0gKyAxLCAtMSk7CiAgICAgICAgfSBlbHNlCiAgICAgICAgewogICAgICAgICAgICBpbnQgZHUgPSBxdWVyeShzdFt1XSk7CiAgICAgICAgICAgIGludCBkdiA9IHF1ZXJ5KHN0W3ZdKTsKICAgICAgICAgICAgaW50IGR6ID0gcXVlcnkoc3Rbel0pOwogICAgICAgICAgICBpZiAoZHUgKyBkdiAtIDIgKiBkeiA+IDApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNvdXQgPDwgIk5PXG4iOwogICAgICAgICAgICAgICAgdnYgPSB2OwogICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY291dCA8PCAiWUVTXG4iOwogICAgICAgICAgICAgICAgdnYgPSB1OwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDA7Cn0K