You are given a tree consisting of n vertices (numbered from 1 to n). Initially all vertices are white. You have to process q queries of two different types:

  1. 1 x — change the color of vertex x to black. It is guaranteed that the first query will be of this type. 
  2. 2 x — for the vertex x, find the minimum index y such that the vertex with index y belongs to the simple path from x to some black vertex (a simple path never visits any vertex more than once). 



For each query of type 2 print the answer to it.

Note that the queries are given in modified way.

Input

The first line contains two numbers n and q (3 ≤ n, q ≤ 106).

Then n - 1 lines follow, each line containing two numbers xi and yi (1 ≤ xi < yi ≤ n) and representing the edge between vertices xi and yi.

It is guaranteed that these edges form a tree.

Then q lines follow. Each line contains two integers ti and zi, where ti is the type of ith query, and zi can be used to restore xi for this query in this way: you have to keep track of the answer to the last query of type 2 (let's call this answer last, and initially last = 0); then xi = (zi + last) mod n + 1.

It is guaranteed that the first query is of type 1, and there is at least one query of type 2.

Output

For each query of type 2 output the answer to it.

Example

Input

4 6
1 2
2 3
3 4
1 2
1 2
2 2
1 3
2 2
2 2


Output

3
2
1
#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;
}
