#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
vector<vector<int>> adj;
const int N = 1e6 + 5;
int mini[N];
int ver;
void dfs(int v, int p) {
  if (v == ver) {
    mini[v] = v;
  } else {
    mini[v] = min(v, mini[p]);
  }
  for (auto u : adj[v]) {
    if (u == p) {
      continue;
    }
    dfs(u, v);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q;
  cin >> n >> q;
  adj.resize(n + 1);
  int last = 0;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int t, x;
  cin >> t >> x;
  x = (x % n) + 1;
  ver = x;
  dfs(x, 0);
  int mins = x;
  for (int i = 0; i < q - 1; i++) {
    int t, x;
    cin >> t >> x;
    x = ((x + last) % n) + 1;
    if (t == 1) {
      mins = min(mins, mini[x]);
    } else {
      int val = min(mins, mini[x]);
      cout << val << '\n';
      last = val;
    }
  }
  return 0;
}
