#include <bits/stdc++.h>
using namespace std;
int N, M, Head[1000000 + 5], Cnt, F[1000000 + 5];
struct Edge {
  int Next, To;
} E[1000000 << 2];
void Add_Edge(int X1, int Y1) {
  E[++Cnt].Next = Head[X1], E[Cnt].To = Y1, Head[X1] = Cnt;
}
void DFS(int X, int Fa) {
  F[X] = min(F[X], X);
  for (int I = Head[X]; I; I = E[I].Next) {
    int Y = E[I].To;
    if (Y == Fa) continue;
    F[Y] = F[X], DFS(Y, X);
  }
}
int main() {
  scanf("%d%d", &N, &M);
  for (int I = 1, X, Y; I < N; I++) {
    scanf("%d%d", &X, &Y);
    Add_Edge(X, Y), Add_Edge(Y, X);
  }
  int X, Lastans = 0, Minx = 0x3f3f3f3f;
  M--, scanf("%d%d", &X, &X);
  memset(F, 0x3f, sizeof(F)), X = X % N + 1, DFS(X, 0);
  while (M--) {
    int Type, X;
    scanf("%d%d", &Type, &X);
    X = (X + Lastans) % N + 1;
    if (Type == 1)
      Minx = min(Minx, F[X]);
    else
      printf("%d\n", Lastans = min(F[X], Minx));
  }
  return 0;
}
