#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int x, int y) {
  ++y;
  return (rng() % (y - x)) + x;
}
int n, q, ans, last, dp[300006 / 3 * 10];
vector<int> v[300006 / 3 * 10];
void dfs(int x, int p) {
  dp[x] = min(x, dp[p]);
  for (auto i : v[x]) {
    if (i != p) {
      dfs(i, x);
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  ans = 1234567890;
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    b = (b + last) % n + 1;
    if (a == 1) {
      if (i == 0) {
        dp[b] = b;
        dfs(b, b);
      }
      ans = min(ans, dp[b]);
    } else {
      cout << (last = min(ans, dp[b])) << "\n";
    }
  }
}
