#include <bits/stdc++.h>
using namespace std;
int n, q, f[1000010], mn, rt, ans;
int cnt, head[1000010], to[2000010], nxt[2000010];
void add(int x, int y) {
  cnt++;
  to[cnt] = y;
  nxt[cnt] = head[x];
  head[x] = cnt;
}
void dfs(int x, int fa, int now) {
  f[x] = now;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = to[i];
    if (y == fa) {
      continue;
    }
    dfs(y, x, min(now, y));
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  q--;
  scanf("%d", &rt);
  scanf("%d", &rt);
  rt = rt % n + 1;
  mn = rt;
  dfs(rt, 0, rt);
  while (q--) {
    int op, x;
    scanf("%d%d", &op, &x);
    x = (x + ans) % n + 1;
    if (op == 1) {
      mn = min(mn, f[x]);
    } else {
      ans = min(mn, f[x]);
      printf("%d\n", ans);
    }
  }
  return 0;
}
