#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int MOD = 1e9 + 7;
const int N = 1000011;
int mini[N], par[N];
int n, q;
vector<int> gr[N];
bool vs[N];
void dfs(int v, int p, int mn) {
  mini[v] = min(mn, v);
  par[v] = p;
  for (auto u : gr[v]) {
    if (u == p) continue;
    dfs(u, v, min(mn, v));
  }
}
int main() {
  scanf("%d", &n), scanf("%d", &q);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d", &u), scanf("%d", &v);
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  bool first = 0;
  int last = 0, x, z;
  int ans = MOD;
  while (q--) {
    int t;
    scanf("%d", &t);
    scanf("%d", &z);
    x = (z + last) % n + 1;
    if (t == 1) {
      if (!first) {
        dfs(x, 0, x);
        first = 1;
      }
      while (par[x] != 0 and !vs[x]) {
        ans = min(ans, x);
        vs[x] = 1;
        x = par[x];
      }
    } else {
      last = min(ans, mini[x]);
      printf("%d\n", last);
    }
  }
  return 0;
}
