#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 6;
const int INF = 1 << 30;
int from_root[MAX];
vector<int> adj[MAX];
int n, q;
void dfs(int source, int father) {
  from_root[source] = min(father == -1 ? INF : from_root[father], source);
  for (auto &each : adj[source]) {
    if (each != father) {
      dfs(each, source);
    }
  }
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = int(0); i < int(n - 1); i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int best = INF, last = 0;
  int x, y;
  scanf("%d %d", &x, &y);
  y = (y + last) % n + 1;
  dfs(y, -1);
  q--;
  while (q--) {
    scanf("%d %d", &x, &y);
    y = (y + last) % n + 1;
    if (x == 1) {
      best = min(best, from_root[y]);
    } else {
      last = min(best, from_root[y]);
      printf("%d\n", last);
    }
  }
  return 0;
}
