#include <bits/stdc++.h>
const int inf = (1ll << 30) - 1;
const int maxn = (int)1e5 + 10;
using namespace std;
int n, q;
vector<int> g[1000100];
int gg[22][1000100];
int p[22][1000100];
int mi = inf;
bool used[1000100];
void dfs(int v, int pa) {
  p[0][v] = pa;
  gg[0][v] = v;
  for (int i = 1; i <= 20; i++) {
    p[i][v] = p[i - 1][p[i - 1][v]];
    gg[i][v] = min(gg[i - 1][v], gg[i - 1][p[i - 1][v]]);
  }
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (to == pa) continue;
    dfs(to, v);
  }
}
int get(int v) {
  int ans = mi;
  for (int i = 20; i >= 0; i--) {
    if (p[i][v] == 0) continue;
    if (used[p[i][v]]) continue;
    ans = min(ans, gg[i][v]);
    v = p[i][v];
  }
  ans = min(ans, v);
  return ans;
}
void go(int v) {
  while (v) {
    if (used[v]) return;
    mi = min(v, mi);
    used[v] = 1;
    v = p[0][v];
  }
}
void solve() {
  scanf("%d%d", &n, &q);
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int last = 0;
  for (int i = 0, t, x; i < q; i++) {
    scanf("%d%d", &t, &x);
    x = (x + last) % n + 1;
    if (!i) {
      dfs(x, 0);
    }
    if (t == 1) {
      go(x);
    } else {
      int ans = get(x);
      printf("%d\n", ans);
      last = ans;
    }
  }
}
int main() {
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
