#include <bits/stdc++.h>
using ll = long long;
using namespace std;

const ll maxn = 3e5 + 5;

struct T {
    ll a, b;
};

ll t, n, q;
vector<vector<ll>> g(maxn, vector<ll>(0)), dp;
vector<T> e(maxn);
vector<bool> used(maxn);

void dfs(ll v, ll p = -1) {
    for (auto i : g[v]) {
        if (used[i]) continue;
        ll to;
        if (e[i].a == v) {
            to = e[i].b;
        } else {
            to = e[i].a;
        }
        if (to == p) continue;
        dfs(to, v);
        dp[v][0] += max(dp[to][0], dp[to][1]);
    }
    for (auto i : g[v]) {
        if (used[i]) continue;
        ll to;
        if (e[i].a == v) {
            to = e[i].b;
        } else {
            to = e[i].a;
        }
        if (to == p) continue;
        dp[v][1] = max(dp[v][1], dp[to][0] + 1 + dp[v][0] - max(dp[to][0], dp[to][1]));
    }
}

void sol() {
    cin >> t >> n;
    for (int i = 1; i <= n - 1; i++) {
        ll a, b; cin >> a >> b;
        e[i] = {a, b};
        g[a].push_back(i);
        g[b].push_back(i);
    }
    cin >> q;
    while (q--) {
        ll type; cin >> type;
        if (type == 1) {
            ll id; cin >> id;
            used[id] = !used[id];
        } else {
            ll x; cin >> x;
            dp.assign(maxn, vector<ll>(2, 0));
            dfs(x);
            cout << max(dp[x][0], dp[x][1]) << '\n';
        }
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll tests = 1;
    //cin >> tests;
    while (tests--) sol();
    return 0;
}
