#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1000003];
int N, Q;
int m[1000003];
void dfs(int u, int p, int incomingMin) {
  m[u] = min(u, incomingMin);
  for (int v : adj[u]) {
    if (v == p) continue;
    dfs(v, u, m[u]);
  }
}
int main() {
  scanf("%d", &N);
  scanf("%d", &Q);
  for (int i = 0; i < N - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int last = 0;
  int t, z;
  scanf("%d %d", &t, &z);
  z = (z % N) + 1;
  int root = z;
  dfs(root, -1, N + 3);
  for (int i = 1; i < Q; i++) {
    scanf("%d %d", &t, &z);
    int u = ((z + last) % N) + 1;
    if (t == 1) {
      m[root] = min(m[root], m[u]);
    } else {
      int ans = min(m[root], m[u]);
      printf("%d\n", ans);
      last = ans;
    }
  }
}
