#include <bits/stdc++.h>
using namespace std;
int last[2000007], pre[2000007], other[2000007], cnt = 0;
int f[2000007];
int n, q, root = 0, mn;
void insert(int u, int v) {
  other[++cnt] = v, pre[cnt] = last[u], last[u] = cnt;
}
void dfs(int u, int fa) {
  for (int q = last[u]; q; q = pre[q]) {
    int v = other[q];
    if (v != fa) {
      f[v] = min(v, f[u]);
      dfs(v, u);
    }
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    insert(u, v), insert(v, u);
  }
  int ans = 0;
  while (q--) {
    int op, x;
    scanf("%d%d", &op, &x);
    x = (x + ans) % n + 1;
    if (op == 1) {
      if (root == 0) {
        root = x;
        mn = root;
        f[root] = root;
        dfs(root, -1);
      } else
        mn = min(mn, f[x]);
    } else {
      ans = min(f[x], mn);
      printf("%d\n", ans);
    }
  }
  return 0;
}
