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, inf = 1e8;
int n, m, sz[N + 2], mark[N + 2];
int anc[N + 2], ans[N + 2], tot;
int dist[22][N + 2], level[N + 2];
vector<int> adj[N + 2];
int reckon(int node, int par) {
  tot++;
  sz[node] = 1;
  for (auto x : adj[node]) {
    if (x == par || mark[x]) continue;
    sz[node] += reckon(x, node);
  }
  return sz[node];
}
int find_center(int node, int par) {
  int mx = -1, nx = -1;
  for (auto x : adj[node]) {
    if (x == par || mark[x]) continue;
    if (sz[x] > tot / 2) return find_center(x, node);
  }
  return node;
}
void cal_dist(int node, int par, int cst, int lv) {
  dist[lv][node] = cst;
  for (auto x : adj[node]) {
    if (x == par || mark[x]) continue;
    cal_dist(x, node, cst + 1, lv);
  }
}
void centroid(int node, int par, int lv) {
  tot = 0;
  reckon(node, -1);
  int center = find_center(node, par);
  anc[center] = par;
  mark[center] = 1;
  level[center] = lv;
  cal_dist(center, -1, 0, lv);
  for (auto x : adj[center]) {
    if (mark[x]) continue;
    centroid(x, center, lv + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  centroid(1, -1, 0);
  for (int i = 1; i <= n; i++) ans[i] = inf;
  int tmp = 1;
  while (tmp != -1) {
    ans[tmp] = min(ans[tmp], dist[level[tmp]][1]);
    tmp = anc[tmp];
  }
  while (m--) {
    int ty, nd;
    cin >> ty >> nd;
    if (ty == 1) {
      int tmp = nd;
      while (nd != -1) {
        ans[nd] = min(ans[nd], dist[level[nd]][tmp]);
        nd = anc[nd];
      }
    } else {
      int tmp = nd, pr = inf;
      while (nd != -1) {
        pr = min(pr, dist[level[nd]][tmp] + ans[nd]);
        nd = anc[nd];
      }
      cout << pr << endl;
    }
  }
  return 0;
}
