#include <bits/stdc++.h>
using namespace std;
vector<int> v[1000010];
int f[1000010], n, m, ans, cmp, x, y;
void dfs(int x, int fa) {
  f[x] = min(x, f[fa]);
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i] == fa) continue;
    dfs(v[x][i], x);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i < n; i++)
    scanf("%d%d", &x, &y), v[x].push_back(y), v[y].push_back(x);
  ans = 0, cmp = 10000000, f[0] = 10000000;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    y = (y + ans) % n + 1;
    if (i == 1) {
      dfs(y, 0);
      continue;
    }
    if (x == 1)
      cmp = min(cmp, f[y]);
    else {
      ans = min(cmp, f[y]);
      printf("%d\n", ans);
    }
  }
}
