#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10, inf = 1e9 + 10;
vector<int> g[MAXN];
int dis[MAXN];
bool black[MAXN];
void dfs(int v, int r = inf, int p = -1) {
  r = min(r, v);
  dis[v] = r;
  for (int u : g[v])
    if (u != p) dfs(u, r, v);
}
int main() {
  ios::sync_with_stdio(false);
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    g[v].push_back(u);
    g[u].push_back(v);
  }
  int x, v;
  scanf("%d%d", &x, &v);
  v = (v % n) + 1;
  dfs(v);
  black[v] = true;
  int last = 0, Min = v;
  for (int i = 1; i < q; i++) {
    scanf("%d%d", &x, &v);
    v = ((v + last) % n) + 1;
    if (x == 2) {
      last = min(Min, dis[v]);
      printf("%d\n", last);
    } else if (!black[v])
      Min = min(Min, dis[v]), black[v] = true;
  }
  return 0;
}
