#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 22;
int n, mn = N + 1, q;
int par[N], ans[N];
bool mark[N];
vector<int> G[N];
void dfs(int v, int p, int rr) {
  rr = min(rr, v);
  ans[v] = rr;
  par[v] = p;
  for (int i = 0; i < (G[v].size()); i++) {
    int u = G[v][i];
    if (u == p) continue;
    dfs(u, v, rr);
  }
}
int main() {
  cin >> n >> q;
  for (int i = 0; i < (n - 1); i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--, v--;
    G[u].push_back(v), G[v].push_back(u);
  }
  q--;
  int x, tp, last = -1;
  cin >> tp >> x;
  x = (x + last + 1) % n;
  mark[x] = true;
  dfs(x, -1, x);
  for (int Q = 0; Q < (q); Q++) {
    scanf("%d%d", &tp, &x);
    x = (x + last + 1) % n;
    if (tp == 1) {
      while (!mark[x]) {
        mark[x] = true;
        mn = min(mn, x);
        x = par[x];
      }
    } else {
      printf("%d\n", min(ans[x], mn) + 1);
      last = min(ans[x], mn);
    }
  }
  return 0;
}
