#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
vector<int> g[N];
int answer, minimum[N];
void dfs(int u, int p) {
  minimum[u] = min(u, minimum[p]);
  for (int v : g[u]) {
    if (v != p) dfs(v, u);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int last = 0;
  int t, x;
  cin >> t >> x;
  assert(t == 1);
  x = (x + last) % n + 1;
  minimum[0] = n + 1;
  dfs(x, 0);
  answer = minimum[x];
  q--;
  while (q--) {
    cin >> t >> x;
    x = (x + last) % n + 1;
    if (t == 1) {
      answer = min(answer, minimum[x]);
    } else {
      last = min(answer, minimum[x]);
      cout << last << '\n';
    }
  }
  return 0;
}
