#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int d[MAXN];
vector<int> k[MAXN];
int t = 0, z = 0, l = 0;
int n, q;
int root;
void fix() { z = (z + l) % n + 1; }
void DFS(int v, int m) {
  m = min(m, v);
  d[v] = m;
  for (int i = 0; i < k[v].size(); i++) {
    int u = k[v][i];
    if (d[u] == 0) DFS(u, m);
  }
}
int main() {
  scanf(" %d %d", &n, &q);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf(" %d %d", &a, &b);
    k[a].push_back(b);
    k[b].push_back(a);
  }
  scanf(" %d %d", &t, &z);
  fix();
  root = z;
  DFS(root, root);
  q--;
  while (q--) {
    scanf(" %d %d", &t, &z);
    fix();
    int curm = min(d[root], d[z]);
    if (t == 1) {
      d[root] = curm;
    } else {
      printf("%d\n", curm);
      l = curm;
    }
  }
}
