#include <bits/stdc++.h>
using namespace std;
const int inf = INT_MAX;
const int N = 1e6 + 1;
vector<int> g[N];
int ans[N];
void dfs(int u, int p) {
  for (int v : g[u])
    if (v != p) {
      ans[v] = min(ans[u], v);
      dfs(v, u);
    }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int last = 0;
  int glob = inf;
  int t, R;
  cin >> t >> R;
  R = R % n + 1;
  ans[R] = R;
  dfs(R, 0);
  for (int i = 1; i < q; ++i) {
    int t, u;
    cin >> t >> u;
    u = (u + last) % n + 1;
    if (t == 1)
      glob = min(glob, ans[u]);
    else {
      last = min(glob, ans[u]);
      cout << last << "\n";
    }
  }
}
