#include <bits/stdc++.h>
using namespace std;
int n, q, k;
vector<int> v[1000010];
int lastans = 0, res[1000010];
void dfs(int np, int fath, int val) {
  res[np] = val;
  for (auto &x : v[np]) {
    if (x == fath) continue;
    dfs(x, np, min(val, x));
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1, ti, tj; i < n; i++) {
    scanf("%d%d", &ti, &tj);
    v[ti].push_back(tj);
    v[tj].push_back(ti);
  }
  int a, b;
  scanf("%d%d", &a, &b);
  b = b % n + 1;
  dfs(b, 0, b);
  lastans = 0;
  k = b;
  for (int i = 2, ti, tj; i <= q; i++) {
    scanf("%d%d", &ti, &tj);
    tj = (tj + lastans) % n + 1;
    if (ti == 1)
      k = min(k, res[tj]);
    else
      printf("%d\n", lastans = min(k, res[tj]));
  }
  return 0;
}
