#include <bits/stdc++.h>
using namespace std;
int n, m, ans[1000003], mi = 1000000007, x, y;
vector<int> G[1000003];
int last_ans = 0;
bool ok = 1;
void dfs(int p, int ant, int val) {
  ans[p] = val = min(val, p);
  for (int i = 0; i < (int)G[p].size(); i++)
    if (G[p][i] != ant) dfs(G[p][i], p, val);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  while (m--) {
    scanf("%d%d", &x, &y);
    y = (y + last_ans) % n + 1;
    if (x == 1) {
      if (ok) dfs(y, 0, y), ok = 0;
      mi = min(mi, ans[y]);
    } else {
      last_ans = min(mi, ans[y]);
      printf("%d\n", last_ans);
    }
  }
}
