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>
int_fast32_t read_int();
constexpr int_fast32_t maxn = 1e6 + 10;
std::vector<int_fast32_t> v[maxn];
int_fast32_t tree_size[maxn];
void calc_size(int_fast32_t x, int_fast32_t p = -1) {
  tree_size[x] = 1;
  for (int_fast32_t i : v[x]) {
    if (i != p) {
      calc_size(i, x);
      tree_size[x] += tree_size[i];
    }
  }
}
bool mark[maxn];
std::pair<int_fast32_t, int_fast32_t> first[maxn], second[maxn];
using pii = std::pair<int_fast32_t, int_fast32_t>;
int_fast32_t parent[maxn];
int_fast32_t parent_size[maxn];
std::vector<int_fast32_t> parent_min[maxn];
inline void add_child(int_fast32_t x, int_fast32_t leader) {
  parent[x] = leader;
  parent_size[x] = parent_size[leader] + 1;
  parent_min[x].resize(parent_size[x]);
}
int_fast32_t current_leader = 0;
void compute_distances(int_fast32_t x, int_fast32_t min, int_fast32_t p = -1) {
  min = std::min(min, x);
  int_fast32_t i = parent_size[x] - parent_size[current_leader] - 1;
  parent_min[x][i] = min;
  for (int_fast32_t i : v[x]) {
    if (!mark[i] && i != p) {
      compute_distances(i, min, x);
    }
  }
}
void decompose(int_fast32_t x, int_fast32_t group_size, int_fast32_t leader) {
  if (group_size == 1) {
    add_child(x, leader);
    return;
  }
  int_fast32_t maxchild = -1;
  for (int_fast32_t i : v[x]) {
    if (mark[i]) continue;
    if (maxchild == -1 || tree_size[i] > tree_size[maxchild]) maxchild = i;
  }
  if (tree_size[maxchild] <= group_size / 2) {
    mark[x] = 1;
    add_child(x, leader);
    for (int_fast32_t i : v[x]) {
      if (mark[i]) continue;
      decompose(i, tree_size[i], x);
      current_leader = x;
      compute_distances(i, x, x);
    }
    mark[x] = 0;
  } else {
    tree_size[x] = group_size - tree_size[maxchild];
    decompose(maxchild, group_size, leader);
  }
}
void try_update(int_fast32_t x, int_fast32_t prev, int_fast32_t ans) {
  std::pair<int_fast32_t, int_fast32_t> a, b, c;
  if (first[x].second == 0)
    a = {1e9, 0};
  else {
    if (first[x].second == prev) {
      a = {std::min(ans, first[x].first), prev};
      ans = 1e9;
    } else {
      a = first[x];
    }
  }
  if (second[x].second == 0)
    b = {1e9, 0};
  else {
    if (second[x].second == prev) {
      b = {std::min(ans, second[x].first), prev};
      ans = 1e9;
    } else {
      b = second[x];
    }
  }
  c = {ans, prev};
  if (a > b) std::swap(a, b);
  if (a > c) std::swap(a, c);
  if (b > c) std::swap(b, c);
  first[x] = a;
  second[x] = b;
  first[x] = first[x];
}
void update(int_fast32_t x) {
  int_fast32_t prev = x, current = x;
  int_fast32_t i = -1;
  try_update(current, prev, x);
  i = 0;
  current = parent[current];
  while (current > 0) {
    try_update(current, prev, parent_min[x][i]);
    prev = current;
    current = parent[current];
    ++i;
  }
}
std::pair<int_fast32_t, int_fast32_t> get_answer(int_fast32_t x,
                                                 int_fast32_t prev) {
  if (first[x].second > 0 && first[x].second != prev) return first[x];
  if (second[x].second > 0) return second[x];
  return {1e9, 0};
}
int_fast32_t query(int_fast32_t x) {
  int_fast32_t prev = -1, current = x;
  std::pair<int_fast32_t, int_fast32_t> ans = get_answer(x, -1);
  int_fast32_t i = 0;
  prev = x;
  current = parent[x];
  while (current > 0) {
    auto cans = get_answer(current, prev);
    if (cans.first != 1e9) cans.first = std::min(cans.first, parent_min[x][i]);
    ans = std::min(ans, cans);
    ++i;
    prev = current;
    current = parent[current];
  }
  return ans.first;
}
int32_t main() {
  int_fast32_t n, q;
  n = read_int();
  q = read_int();
  for (int_fast32_t i = 0; i < n - 1; i++) {
    int_fast32_t x, y;
    x = read_int();
    y = read_int();
    v[x].push_back(y);
    v[y].push_back(x);
  }
  std::srand(std::chrono::system_clock::now().time_since_epoch().count());
  int_fast32_t random_root = std::rand() % n + 1;
  calc_size(random_root);
  decompose(random_root, n, 0);
  int_fast32_t last = 0;
  while (q-- > 0) {
    int_fast32_t t, z;
    t = read_int();
    z = read_int();
    int_fast32_t x = (last + z) % n + 1;
    if (t == 1) {
      update(x);
    } else {
      last = query(x);
      printf("%ld\n", last);
    }
  }
  return 0;
}
const int_fast32_t maxl = 100000;
char buff[maxl];
int_fast32_t ret_int, pos_buff = 0;
void next_char() {
  if (++pos_buff == maxl) fread(buff, 1, maxl, stdin), pos_buff = 0;
}
int_fast32_t read_int() {
  ret_int = 0;
  for (; buff[pos_buff] < '0' || buff[pos_buff] > '9'; next_char())
    ;
  for (; buff[pos_buff] >= '0' && buff[pos_buff] <= '9'; next_char())
    ret_int = ret_int * 10 + buff[pos_buff] - '0';
  return ret_int;
}
