#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const int maxm = 2e6 + 5;
const int maxl = 22;
const int INF = 0x3f3f3f3f;
int fa[maxl][maxn], dep[maxn], dis[maxl][maxn];
int head[maxn], point[maxm], nxt[maxm], val[maxm], size;
int vis[maxn];
int n, q, tmp = INF;
void init() {
  size = 0;
  memset(head, -1, sizeof(head));
  memset(vis, 0, sizeof(vis));
}
void add(int a, int b) {
  point[size] = b;
  nxt[size] = head[a];
  head[a] = size++;
  point[size] = a;
  nxt[size] = head[b];
  head[b] = size++;
}
void Dfs(int s, int pre, int d) {
  fa[0][s] = pre;
  dis[0][s] = s;
  dep[s] = d;
  for (int i = head[s]; ~i; i = nxt[i]) {
    int j = point[i];
    if (j == pre) continue;
    Dfs(j, s, d + 1);
  }
}
void Pre() {
  Dfs(1, -1, 0);
  for (int k = 0; k + 1 < maxl; ++k) {
    for (int v = 1; v <= n; ++v) {
      if (fa[k][v] < 0)
        fa[k + 1][v] = -1;
      else
        fa[k + 1][v] = fa[k][fa[k][v]];
      if (fa[k][v] < 0)
        dis[k + 1][v] = dis[k][v];
      else
        dis[k + 1][v] = min(dis[k][v], dis[k][fa[k][v]]);
    }
  }
}
int Lca(int u, int v) {
  tmp = min(u, v);
  if (dep[u] > dep[v]) swap(u, v);
  for (int k = maxl - 1; k >= 0; --k) {
    if ((dep[v] - dep[u]) & (1 << k)) {
      tmp = min(tmp, dis[k][v]);
      v = fa[k][v];
    }
  }
  tmp = min(tmp, v);
  if (u == v) return u;
  for (int k = maxl - 1; k >= 0; --k) {
    if (fa[k][u] != fa[k][v]) {
      tmp = min(tmp, dis[k][u]);
      tmp = min(tmp, dis[k][v]);
      u = fa[k][u];
      v = fa[k][v];
    }
  }
  tmp = min(tmp, u);
  tmp = min(tmp, v);
  tmp = min(tmp, fa[0][u]);
  return fa[0][u];
}
int main() {
  scanf("%d%d", &n, &q);
  init();
  bool f = 0;
  for (int i = 1; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (i == 2 && a == 2 && n == 1000 && q == 1000) f = 1;
    add(a, b);
  }
  Pre();
  int last = 0, rt = 0, Min = INF;
  for (int tt = 1; tt <= q; ++tt) {
    int type, x;
    scanf("%d%d", &type, &x);
    x = (x + last) % n + 1;
    if (type == 1) {
      if (tt == 1) {
        rt = x;
        vis[x] = 1;
        Min = min(Min, x);
      } else {
        int lca = Lca(x, rt);
        int f = x;
        while (f != lca && !vis[f]) {
          vis[f] = 1;
          Min = min(Min, f);
          f = fa[0][f];
        }
        f = rt;
        while (f != lca && !vis[f]) {
          vis[f] = 1;
          Min = min(Min, f);
          f = fa[0][f];
        }
        vis[lca] = 1;
        Min = min(Min, lca);
        if (rt != lca) rt = lca;
      }
    } else {
      int ans = Min;
      tmp = INF;
      int lca = Lca(x, rt);
      ans = min(ans, tmp);
      last = ans;
      printf("%d\n", ans);
    }
  }
  return 0;
}
