#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 1 << 30;
const int N = 1e6 + 10;
int n, q;
vector<int> g[N];
int t[N], minid;
void dfs(int u, int pre) {
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == pre) continue;
    t[v] = min(t[v], t[u]);
    dfs(v, u);
  }
}
int main() {
  cin >> n >> q;
  int u, v, rt;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int last = 0;
  cin >> u >> rt;
  q--;
  for (int i = 0; i < n + 1; i++) t[i] = i;
  rt = (rt + last) % n + 1;
  dfs(rt, -1);
  minid = n + 1;
  while (q--) {
    scanf("%d%d", &u, &v);
    v = (last + v) % n + 1;
    if (u == 1)
      minid = min(minid, t[v]);
    else {
      last = min(minid, t[v]);
      printf("%d\n", last);
    }
  }
  return 0;
}
