#include <bits/stdc++.h>
using namespace std;
int n, q;
int last;
vector<int> g[1000000];
int mn[1000000];
int global_min;
void dfs(int cur, int pr = -1, int prop = n) {
  prop = (prop > cur + 1 ? cur + 1 : prop);
  mn[cur] = prop;
  for (int i = 0; i < g[cur].size(); i++)
    if (g[cur][i] != pr) dfs(g[cur][i], cur, prop);
}
int main() {
  scanf("%d %d", &n, &q);
  global_min = n;
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    g[--v].push_back(--u);
    g[u].push_back(v);
  }
  int t, z, x;
  scanf("%d %d", &t, &z);
  x = (z + last) % n;
  dfs(x);
  for (int i = 1; i < q; i++) {
    scanf("%d %d", &t, &z);
    x = (z + last) % n;
    if (t == 1) {
      global_min = (global_min > mn[x] ? mn[x] : global_min);
    } else {
      last = (mn[x] > global_min ? global_min : mn[x]);
      printf("%d\n", last);
    }
  }
  return 0;
}
