#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long a = 0, b = getchar(), c = 1;
  while (!isdigit(b)) c = b == '-' ? -1 : 1, b = getchar();
  while (isdigit(b)) a = a * 10 + b - '0', b = getchar();
  return a * c;
}
int n, q, s, rt, mn, f[1000005];
vector<int> g[1000005];
void dfs(int x, int y) {
  f[x] = min(f[y], x);
  for (int i = 0; i < g[x].size(); i++)
    if (g[x][i] != y) dfs(g[x][i], x);
}
int main() {
  n = read(), q = read();
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    g[x].push_back(y);
    g[y].push_back(x);
  }
  read();
  mn = rt = read() % n + 1;
  f[0] = rt;
  dfs(rt, 0);
  for (int i = 2; i <= q; i++) {
    int t = read(), x = (read() + s) % n + 1;
    if (t == 1)
      mn = min(mn, f[x]);
    else
      printf("%d\n", s = min(f[x], mn));
  }
  return 0;
}
