#include <bits/stdc++.h>
using namespace std;
int n, q, root, ans[1010100], ult, mini, jav[1010100], pai[1010100];
vector<int> adj[1010100];
void dfs(int v) {
  ans[v] = min(v, ans[pai[v]]);
  for (int(i) = (0); (i) < (((int)(adj[v]).size())); (i)++)
    if (pai[v] != adj[v][i]) {
      pai[adj[v][i]] = v;
      dfs(adj[v][i]);
    }
}
void sobe(int v) {
  if (jav[v]) return;
  jav[v] = 1;
  mini = min(mini, v);
  sobe(pai[v]);
}
int main() {
  scanf("%d%d", &n, &q);
  for (int(i) = (1); (i) < (n); (i)++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[v].push_back(u), adj[u].push_back(v);
  }
  q--;
  scanf("%d%d", new int, &root);
  root = root % n + 1;
  mini = ans[root] = pai[root] = root;
  dfs(root);
  jav[root] = 1;
  while (q--) {
    int tp, v;
    scanf("%d%d", &tp, &v);
    v = (v + ult) % n + 1;
    if (tp == 1)
      sobe(v);
    else
      printf("%d\n", ult = min(ans[v], mini));
  }
}
