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;
inline void smin(long long int &x, const long long int y) { x = min(x, y); }
const long long int M = 1e5 + 5, SM = 320;
const long long int inf = 1e18;
const long long int LG = 18;
const long long int Z = 26;
basic_string<long long int> g[M];
long long int n, q;
long long int d[M];
long long int h[M];
long long int par[LG][M];
void dfs(long long int x) {
  for (long long int i = (1); i < (LG); i++) {
    par[i][x] = par[i - 1][par[i - 1][x]];
  }
  for (long long int y : g[x]) {
    if (y == par[0][x]) continue;
    par[0][y] = x;
    d[y] = d[x] + 1;
    h[y] = h[x] + 1;
    dfs(y);
  }
}
long long int lca(long long int u, long long int v) {
  if (h[v] > h[u]) swap(u, v);
  for (long long int i = (LG - 1); i >= (0); i--) {
    if (h[u] - (1 << i) >= h[v]) {
      u = par[i][u];
    }
  }
  if (u == v) return u;
  for (long long int i = (LG - 1); i >= (0); i--) {
    if (par[i][u] != par[i][v]) {
      u = par[i][u];
      v = par[i][v];
    }
  }
  u = par[0][u];
  return u;
}
long long int dis(long long int u, long long int v) {
  long long int uv = lca(u, v);
  return h[v] + h[u] - 2 * h[uv];
}
int main() {
  cin >> n >> q;
  for (long long int i = (1); i < (n); i++) {
    long long int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u] += v;
    g[v] += u;
  }
  dfs(0);
  for (long long int rep = (0); rep < (q / SM + 1); rep++) {
    basic_string<long long int> tmp;
    for (long long int i = (0); i < (rep == q / SM ? q % SM : SM); i++) {
      long long int t, v;
      cin >> t >> v;
      v--;
      if (t == 1) {
        tmp += v;
      } else if (t == 2) {
        long long int res = d[v];
        for (long long int x : tmp) {
          smin(res, dis(x, v));
        }
        cout << res << '\n';
      }
    }
    queue<long long int> qu;
    for (long long int x : tmp) {
      d[x] = 0;
      qu.push(x);
    }
    while (((long long int)qu.size()) > 0) {
      long long int x = qu.front();
      qu.pop();
      for (long long int y : g[x]) {
        if (d[y] > d[x] + 1) {
          d[y] = d[x] + 1;
          qu.push(y);
        }
      }
    }
  }
}
