#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1000010];
int mn[1000010];
int root;
void dfs(int x, int p) {
  mn[x] = min(x, mn[p]);
  for (int u : adj[x])
    if (u - p) dfs(u, x);
}
int main() {
  ios::sync_with_stdio(0);
  int n, m, q;
  cin >> n >> q;
  q--;
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int _a;
  int last = 0;
  cin >> _a >> root;
  root = ((root + last) % n) + 1;
  mn[root] = root;
  dfs(root, root);
  while (q--) {
    int t, x;
    cin >> t >> x;
    x = (x + last) % n + 1;
    if (t == 1) {
      mn[root] = min(mn[root], mn[x]);
    } else {
      last = min(mn[root], mn[x]);
      printf("%d\n", last);
    }
  }
}
