#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 1000 + 20, inf = 1e9;
int n, q, mn[N], MN, par[N], last;
bool mark[N];
vector<int> adj[N];
void dfs(int v, int Par = -1) {
  par[v] = Par;
  mn[v] = min(mn[v], v);
  for (auto u : adj[v])
    if (u ^ Par) {
      mn[u] = mn[v];
      dfs(u, v);
    }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    int v, u;
    cin >> v >> u;
    adj[--v].push_back(--u);
    adj[u].push_back(v);
  }
  q--;
  int type, root, v;
  cin >> type >> root;
  fill(mn, mn + n, inf);
  MN = root;
  dfs(root);
  mark[root] = true;
  while (q--) {
    cin >> type >> v;
    v = ((last + v) % n + n) % n;
    if (type == 1) {
      while (~v && !mark[v]) {
        mark[v] = true;
        MN = min(MN, v);
        v = par[v];
      }
    } else {
      cout << min(mn[v], MN) + 1 << "\n";
      last = min(mn[v], MN) + 1;
    }
  }
}
