#include <bits/stdc++.h>
using namespace std;
long long modpow(long long b, long long e, long long mod) {
  long long ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}
const int inf = (int)1e9;
const int N = 1000005;
int dp[N], ans = inf, n, q, pai[N], vis[N];
vector<int> g[N];
void dfs(int x, int p = -1) {
  if (p == -1)
    dp[x] = x;
  else
    dp[x] = min(x, dp[p]);
  for (auto w : g[x]) {
    if (w != p) dfs(w, x), pai[w] = x;
  }
}
int32_t main() {
  for (int i = 0; i < (N); ++i) dp[i] = inf;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int last = 0;
  bool jf = false;
  while (q--) {
    int t, x;
    scanf("%d%d", &t, &x);
    if (t == 1) {
      if (jf == 0) {
        jf = 1;
        x = (x + last) % n + 1;
        dfs(x);
      } else {
        x = (x + last) % n + 1;
        while (x && !vis[x]) {
          vis[x] = true;
          ans = min(ans, x);
          x = pai[x];
        }
      }
    } else {
      x = (x + last) % n + 1;
      printf("%d\n", (last = min(dp[x], ans)));
    }
  }
}
