#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e6 + 6;
vector<int> g[mxn];
int n, k, root;
int ans[mxn];
int curmin, last;
inline void dfs(int x, int par = -1, int mn = root) {
  ans[x] = mn;
  for (int i = 0; i < g[x].size(); ++i) {
    int y = g[x][i];
    if (y == par) continue;
    dfs(y, x, min(mn, y));
  }
}
inline void solve() {
  cin >> n >> k;
  for (int i = 1, u, v; i < n; ++i) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int tp, x;
  cin >> tp >> x;
  x = (x + last) % n + 1;
  root = x;
  dfs(root);
  curmin = root;
  for (k--; k--;) {
    cin >> tp >> x;
    x = (x + last) % n + 1;
    if (tp == 1)
      curmin = min(curmin, ans[x]);
    else
      cout << min(curmin, ans[x]) << '\n', last = min(curmin, ans[x]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int T;
  T = 1;
  for (; T--;) solve();
}
