#include <bits/stdc++.h>
using namespace std;
int a[1200005];
int vis[1200005];
int path[1200005];
int n, q;
int global = n;
vector<vector<int>> g;
void dfs(int x, int p = -1) {
  for (auto it : g[x]) {
    if (it == p) continue;
    a[it] = min(a[x], it);
    dfs(it, x);
  }
}
int main() {
  cin >> n >> q;
  g = vector<vector<int>>(n + 1);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int last = 0;
  q--;
  int cmd;
  int x;
  scanf("%d", &cmd);
  scanf("%d", &x);
  a[(x + last) % n + 1] = (x + last) % n + 1;
  dfs((x + last) % n + 1);
  global = a[(x + last) % n + 1];
  while (q--) {
    scanf("%d", &cmd);
    scanf("%d", &x);
    if (cmd == 1) {
      x = (x + last) % n + 1;
      global = min(global, a[x]);
    } else {
      x = (x + last) % n + 1;
      int ans = min(global, a[x]);
      printf("%d\n", ans);
      last = ans;
    }
  }
}
