#include <bits/stdc++.h>
using namespace std;
vector<int> a[1000010];
int par[1000010], cnt, in[1000010], out[1000010], elr[1000010];
void dfs2(int x, int papa) {
  int nxt;
  par[x] = papa;
  elr[cnt] = x;
  in[x] = cnt;
  ++cnt;
  for (int i = 0; i < a[x].size(); ++i) {
    nxt = a[x][i];
    if (nxt == papa) continue;
    dfs2(nxt, x);
  }
  out[x] = cnt - 1;
}
int lf, rt, val, pr[4000010];
void updt(int x, int st, int nd) {
  if (st > rt || nd < lf) return;
  if (pr[x] < val) return;
  if (st >= lf && nd <= rt) {
    pr[x] = min(pr[x], val);
    return;
  }
  int md = (st + nd) / 2;
  pr[x * 2] = min(pr[x * 2], pr[x]);
  pr[x * 2 + 1] = min(pr[x * 2 + 1], pr[x]);
  updt(x * 2, st, md);
  updt(x * 2 + 1, md + 1, nd);
}
void init(int x, int st, int nd) {
  pr[x] = 1e9;
  if (st == nd) {
    pr[x] = elr[st];
    return;
  }
  int md = (st + nd) / 2;
  init(x * 2, st, md);
  init(x * 2 + 1, md + 1, nd);
}
int qry(int x, int st, int nd) {
  if (st > rt || nd < lf) return 1e9;
  if (st == nd) {
    return pr[x];
  }
  int md = (st + nd) / 2;
  pr[x * 2] = min(pr[x * 2], pr[x]);
  pr[x * 2 + 1] = min(pr[x * 2 + 1], pr[x]);
  return min(qry(x * 2, st, md), qry(x * 2 + 1, md + 1, nd));
}
void ddfs(int x, int papa) {
  int nxt;
  if (papa == -1) {
    pr[1] = min(pr[1], x);
  }
  bool l = 0;
  for (int i = 0; i < a[x].size(); ++i) {
    nxt = a[x][i];
    if (nxt == papa) {
      l = 1;
      continue;
    }
    if (nxt == par[x]) {
      lf = 0;
      rt = in[x] - 1;
      val = x;
      updt(1, 0, cnt - 1);
      lf = out[x] + 1;
      rt = cnt - 1;
      val = x;
      updt(1, 0, cnt - 1);
    } else {
      lf = in[nxt];
      rt = out[nxt];
      val = x;
      updt(1, 0, cnt - 1);
    }
    ddfs(nxt, x);
  }
  a[x].clear();
  if (l) {
    a[x].push_back(papa);
  }
}
int main() {
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d%d", &x, &y);
    a[x].push_back(y);
    a[y].push_back(x);
  }
  dfs2(1, -1);
  init(1, 0, cnt - 1);
  int ans = 0, t, z;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &t, &z);
    x = (z + ans) % n + 1;
    if (t == 1) {
      ddfs(x, -1);
    } else {
      lf = rt = in[x];
      ans = qry(1, 0, cnt - 1);
      printf("%d\n", ans);
    }
  }
  return 0;
}
