#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2111111;
int n, ques, fa[MAXN], idx[MAXN], cover[MAXN];
vector<int> e[MAXN];
inline void dfs(int u, int father, int min_index) {
  idx[u] = min_index;
  fa[u] = father;
  for (auto v : e[u]) {
    if (v != father) {
      dfs(v, u, min(min_index, v));
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> ques;
  for (int i = 1; i < n; ++i) {
    static int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  int root = -1, ans = 0, min_index = n + 1;
  int cnt = 0;
  for (; ques; --ques) {
    int type, u;
    cin >> type >> u;
    u += ans;
    if (u >= n) {
      u -= n;
    }
    if (u >= n) {
      u -= n;
    }
    u += 1;
    if (type == 1) {
      if (root == -1) {
        root = u;
        cover[root] = 1;
        min_index = u;
        dfs(u, 0, u);
      } else {
        while (!cover[u]) {
          min_index = min(min_index, u);
          cover[u] = 1;
          u = fa[u];
        }
      }
    } else {
      if (root == -1) {
        ans = u;
      } else {
        ans = min(idx[u], min_index);
      }
      cout << ans << "\n";
    }
  }
}
