#include <bits/stdc++.h>
using namespace std;
template <typename T>
T next_int() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return p * x;
}
string next_token() {
  char ch;
  string ans = "";
  do {
    ch = getchar();
  } while (ch <= ' ');
  while (ch > ' ') {
    ans += ch;
    ch = getchar();
  }
  return ans;
}
const long long INF = (long long)1e18;
const int INFINT = (int)1e9 + 227 + 1;
const int MAXN = (int)1e6 + 227 + 1;
const int MOD = (int)1e9 + 7;
const long double EPS = 1e-9;
long long bin_pow(long long a, long long b) {
  if (!b) return 1;
  long long ans = bin_pow(a, b / 2);
  ans = ans * ans;
  if (b % 2) ans = ans * a;
  return ans;
}
vector<int> a[MAXN];
int min_edge[MAXN];
void go(int v, int pr = -1, int kek = INFINT) {
  kek = min(kek, v);
  min_edge[v] = kek;
  for (int i = 0; i < a[v].size(); i++) {
    if (a[v][i] == pr) continue;
    go(a[v][i], v, kek);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i < n; i++) {
    int x = next_int<int>() - 1;
    int y = next_int<int>() - 1;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  int ans = INFINT;
  int last = 0;
  for (int i = 0; i < m; i++) {
    int type = next_int<int>();
    int v = (next_int<int>() + last) % n;
    if (type == 1) {
      if (i == 0) go(v);
      ans = min(ans, min_edge[v]);
    } else {
      last = min(ans, min_edge[v]) + 1;
      printf("%d\n", last);
    }
  }
}
