#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
  return x * f;
}
const int N = 1e6 + 5;
int cnt, head[N], Min[N], mm, q, n, root, u, v, op, x, last;
struct node {
  int to, next;
} num[N * 2];
void add(int x, int y) {
  num[++cnt].to = y;
  num[cnt].next = head[x];
  head[x] = cnt;
}
void dfs(int x, int fa) {
  for (int i = head[x]; i; i = num[i].next)
    if (num[i].to != fa) {
      Min[num[i].to] = min(Min[x], num[i].to);
      dfs(num[i].to, x);
    }
}
int main() {
  n = read();
  q = read();
  for (int i = 1; i < n; i++) u = read(), v = read(), add(u, v), add(v, u);
  q--;
  op = read();
  root = read() % n + 1;
  Min[root] = root;
  dfs(root, -1);
  mm = root;
  while (q--) {
    op = read();
    x = read();
    x = (x + last) % n + 1;
    if (op == 1)
      mm = min(mm, Min[x]);
    else
      printf("%d\n", last = min(mm, Min[x]));
  }
  return 0;
}
