#include <bits/stdc++.h>
using namespace std;
int n, q, rt, las, Min[1000015], ans;
vector<int> e[1000015];
void dfs(int u, int fa) {
  Min[u] = min(u, Min[fa]);
  for (auto v : e[u])
    if (v != fa) {
      dfs(v, u);
    }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  int opt, x;
  scanf("%d%d", &opt, &x);
  x = (x + las) % n + 1;
  rt = x;
  Min[0] = 0x3f3f3f3f;
  dfs(x, 0);
  ans = 0x3f3f3f3f;
  for (int i = 2; i <= q; i++) {
    scanf("%d%d", &opt, &x);
    x = (x + las) % n + 1;
    if (opt == 1)
      ans = min(ans, Min[x]);
    else
      printf("%d\n", las = min(ans, Min[x]));
  }
  return 0;
}
