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 maxn = 1e5 + 20;
int T = 120;
vector<int> adj[maxn];
vector<int> reds;
int ans[maxn];
int mark[maxn];
int h[maxn];
int par[20][maxn];
int inf = 1e9;
void bfs() {
  fill(mark, mark + maxn, 0);
  queue<int> q;
  for (int i : reds) {
    ans[i] = 0;
    q.push(i);
    mark[i] = 1;
  }
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int u : adj[v]) {
      if (!mark[u]) {
        ans[u] = ans[v] + 1;
        q.push(u);
        mark[u] = 1;
      }
    }
  }
}
void dfs(int v, int p) {
  for (int u : adj[v]) {
    if (u != p) {
      h[u] = h[v] + 1;
      par[0][u] = v;
      for (int i = 1; i < 20; i++) {
        par[i][u] = par[i - 1][par[i - 1][u]];
      }
      dfs(u, v);
    }
  }
}
int dis(int u, int v) {
  int res = 0;
  if (h[u] > h[v]) {
    swap(u, v);
  }
  int dif = h[v] - h[u];
  res += dif;
  int tmp = 0;
  while (dif) {
    if (dif & 1) {
      v = par[tmp][v];
    }
    tmp++;
    dif /= 2;
  }
  if (u == v) {
    return res;
  }
  for (int i = 19; i >= 0; i--) {
    if (par[i][v] != par[i][u]) {
      res += (1 << i + 1);
      v = par[i][v];
      u = par[i][u];
    }
  }
  res += 2;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  fill(ans, ans + maxn, inf);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  dfs(1, -1);
  vector<int> Q;
  Q.push_back(1);
  reds.push_back(1);
  int cnt = 0;
  while (q--) {
    cnt++;
    int t, x;
    cin >> t >> x;
    if (t == 1) {
      Q.push_back(x);
      reds.push_back(x);
    } else {
      for (int y : Q) {
        ans[x] = min(ans[x], dis(x, y));
      }
      cout << ans[x] << "\n";
    }
    if (cnt >= T) {
      cnt = 0;
      bfs();
      Q.clear();
    }
  }
  return 0;
}
