#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q;
  cin >> n >> q;
  vector<int> res(n + 1, 0);
  vector<vector<int>> adjacenyList(n + 1);
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adjacenyList[u].emplace_back(v);
    adjacenyList[v].emplace_back(u);
  }
  function<void(int, int)> DFS = [&](int u, int val) {
    res[u] = val;
    for (int v : adjacenyList[u]) {
      if (res[v]) continue;
      DFS(v, min(v, val));
    }
  };
  int c = 0, l = 0;
  int t, x;
  cin >> t >> x;
  x = (x + l) % n + 1;
  c = x;
  DFS(x, x);
  while (--q) {
    cin >> t >> x;
    x = (x + l) % n + 1;
    if (t & 1) {
      c = min(c, res[x]);
    } else {
      l = min(c, res[x]);
      cout << l << '\n';
    }
  }
}
