#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, inf = 1e9 + 10;
int mn[N];
vector<int> g[N];
void dfs(int v, int p) {
  mn[v] = min(mn[p], v);
  for (int u : g[v])
    if (u != p) dfs(u, v);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(mn, 63, sizeof(mn));
  int n, q, lst = 0, u, v, type, ans = inf;
  cin >> n >> q;
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  cin >> type >> v;
  v %= n;
  dfs(v, v);
  for (int i = 0; i < q - 1; i++) {
    cin >> type >> v;
    v = (v + lst) % n;
    if (type == 1)
      ans = min(ans, mn[v]);
    else {
      cout << min(ans, mn[v]) + 1 << "\n";
      lst = min(ans, mn[v]) + 1;
    }
  }
  return 0;
}
