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 long long N = 100001, M = 22;
set<long long> v[N];
long long sz[N], cpar[N], level[N], dist[M][N], ans[N];
long long nodes = 0;
void dfs(long long node, long long par, long long lvl) {
  nodes++;
  sz[node] = 1;
  dist[lvl][node] = dist[lvl][par] + 1;
  for (auto c : v[node]) {
    if (c == par) continue;
    dfs(c, node, lvl);
    sz[node] += sz[c];
  }
}
long long cent(long long node, long long par = 0) {
  for (auto c : v[node]) {
    if (c == par) continue;
    if (sz[c] > (nodes / 2)) return cent(c, node);
  }
  return node;
}
void make(long long vert, long long cent_par = 0) {
  nodes = 0;
  dfs(vert, 0, level[cent_par]);
  long long child = cent(vert);
  cpar[child] = cent_par;
  level[child] = level[cent_par] + 1;
  for (auto c : v[child]) {
    v[c].erase(child);
    make(c, child);
  }
}
long long lca(long long u, long long v) {
  while (level[u] < level[v]) v = cpar[v];
  while (level[u] > level[v]) u = cpar[u];
  while (u != v) {
    u = cpar[u];
    v = cpar[v];
  }
  return u;
}
long long distance(long long u, long long v) {
  long long l = lca(u, v);
  return dist[level[l]][u] + dist[level[l]][v];
}
void update(long long node) {
  long long u = node;
  while (node != 0) {
    ans[node] = min(ans[node], distance(node, u));
    node = cpar[node];
  }
}
long long query(long long node) {
  long long a = 1e18;
  long long u = node;
  while (node != 0) {
    a = min(a, ans[node] + distance(u, node));
    node = cpar[node];
  }
  return a;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i <= n; i++) ans[i] = 1e18;
  for (long long i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    v[a].insert(b);
    v[b].insert(a);
  }
  make(1);
  update(1);
  while (m--) {
    long long type;
    cin >> type;
    if (type == 1) {
      long long node;
      cin >> node;
      update(node);
    } else {
      long long node;
      cin >> node;
      cout << query(node) << "\n";
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
