#include <bits/stdc++.h>
using namespace std;
static const int maxn = 1000000 + 10;
int n, q, root, d[maxn], par[maxn];
vector<int> e[maxn];
bool v[maxn];
void dfs(int x, int p) {
  if (!p) d[x] = x;
  for (int i = 0; i < e[x].size(); i++) {
    if (e[x][i] == p) continue;
    d[e[x][i]] = min(d[x], e[x][i]);
    par[e[x][i]] = x;
    dfs(e[x][i], x);
  }
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  int last = 0, mn = n;
  for (int i = 0; i < q; i++) {
    int t, z;
    scanf("%d %d", &t, &z);
    int x = (z + last) % n + 1;
    if (i) {
      if (t == 1) {
        while (!v[x]) {
          v[x] = true;
          mn = min(mn, x);
          x = par[x];
        }
      } else {
        last = min(mn, d[x]);
        printf("%d\n", last);
      }
    } else {
      mn = root = x;
      v[root] = true;
      dfs(root, 0);
    }
  }
  return 0;
}
