#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000000 + 7;
int dp[MAX_N];
vector<int> G[MAX_N];
void dfs(int u, int fa) {
  dp[u] = min(u, dp[fa]);
  for (int v : G[u]) {
    if (v != fa) dfs(v, u);
  }
}
int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);
  for (int i = 1; i < N; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  int ans = 0;
  int global_mn = N;
  dp[0] = N;
  for (int i = 0; i < Q; i++) {
    int op, x;
    scanf("%d%d", &op, &x);
    x = (x + ans) % N + 1;
    if (op == 1) {
      if (!i) dfs(x, 0);
      global_mn = min(global_mn, dp[x]);
    } else {
      ans = min(dp[x], global_mn);
      printf("%d\n", ans);
    }
  }
  return 0;
}
