Xenia the programmer has a tree consisting of n nodes. We will consider the tree nodes indexed from 1 to n. We will also consider the first node to be initially painted red, and the other nodes — to be painted blue.

The distance between two tree nodes v and u is the number of edges in the shortest path between v and u.

Xenia needs to learn how to quickly execute queries of two types:

  1. paint a specified blue node in red; 
  2. calculate which red node is the closest to the given one and print the shortest distance to the closest red node. 



Your task is to write a program which will execute the described queries.

Input

The first line contains two integers n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of nodes in the tree and the number of queries. Next n - 1 lines contain the tree edges, the i-th line contains a pair of integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — an edge of the tree.

Next m lines contain queries. Each query is specified as a pair of integers ti, vi (1 ≤ ti ≤ 2, 1 ≤ vi ≤ n). If ti = 1, then as a reply to the query we need to paint a blue node vi in red. If ti = 2, then we should reply to the query by printing the shortest distance from some red node to node vi.

It is guaranteed that the given graph is a tree and that all queries are correct.

Output

For each second type query print the reply in a single line.

Examples

Input

5 4
1 2
2 3
2 4
4 5
2 1
2 5
1 2
2 5


Output

0
3
2
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100, LG = 35;
const int SQ = sqrt(N);
long long int dp[N][LG], mn[N], mas, pw[LG], h[N];
vector<long long int> v[N];
deque<long long int> w;
void dfs(int x, int parx = -1) {
  dp[x][0] = parx;
  for (int i = 1; i < 30; i++) {
    if (dp[x][i - 1] != -1)
      dp[x][i] = dp[dp[x][i - 1]][i - 1];
    else
      break;
  }
  for (int u : v[x]) {
    if (u != parx) {
      h[u] = h[x] + 1;
      dfs(u, x);
    }
  }
}
void relax() {
  for (int u : w) {
    mn[u] = 0;
  }
  while (w.size() > 0) {
    int f = w.front();
    w.pop_front();
    for (int u : v[f]) {
      if (mn[u] > mn[f] + 1) {
        w.push_back(u);
        mn[u] = mn[f] + 1;
      }
    }
  }
}
void find_par(int u1, int u2) {
  if (h[u1] < h[u2]) swap(u1, u2);
  long long int up1 = h[u1] - h[u2];
  for (int i = 29; i >= 0; i--) {
    if (pw[i] <= up1) {
      up1 -= pw[i];
      u1 = dp[u1][i];
      mas += pw[i];
    }
  }
  if (u1 == u2) return;
  for (int i = 29; i >= 0; i--) {
    if (dp[u1][i] != dp[u2][i]) {
      u1 = dp[u1][i];
      u2 = dp[u2][i];
      mas += pw[i] * 2;
    }
  }
  mas += 2;
}
int main() {
  pw[0] = 1;
  for (int i = 1; i < 30; i++) pw[i] = pw[i - 1] * 2;
  memset(dp, -1, sizeof(dp));
  memset(mn, 63, sizeof(mn));
  long long int n, m;
  cin >> n >> m;
  for (int i = 0; i < n - 1; i++) {
    long long int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(0);
  w.push_back(0);
  for (int i = 0; i < m; i++) {
    if (i % SQ == 0) {
      relax();
      w.clear();
    }
    long long int op, no;
    cin >> op >> no;
    no--;
    if (op == 1) {
      w.push_back(no);
    } else {
      long long int ans = mn[no];
      for (int u : w) {
        mas = 0;
        find_par(u, no);
        ans = min(mas, ans);
      }
      cout << ans << '\n';
    }
  }
}
