#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int inf = 1e9;
vector<int> g[maxn];
int best[maxn];
bool was[maxn];
int p[maxn];
void dfs(int v, int pp = 0) {
  p[v] = pp;
  best[v] = min(v, best[pp]);
  for (int x : g[v])
    if (x != pp) dfs(x, v);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  fill(best, best + maxn, inf);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int last = 0;
  q--;
  int t, x, z;
  cin >> t >> z;
  x = (z + last) % n + 1;
  dfs(x);
  was[x] = 1;
  int globmin = x;
  while (q--) {
    cin >> t >> z;
    x = (z + last) % n + 1;
    if (t == 1) {
      while (!was[x]) {
        was[x] = 1;
        globmin = min(globmin, x);
        x = p[x];
      }
    } else {
      last = min(best[x], globmin);
      cout << last << '\n';
    }
  }
  return 0;
}
