#include "Encoder.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 250005;
vector<int> adj[MAXN];
ll ind = -1;
void dfs(int x, int par){
ll st = ++ind;
for (int nn : adj[x]){
if (nn == par) continue;
dfs(nn, x);
}
Code(x, st * MAXN + ind);
}
void Encode(int N, int A[], int B[]) {
for (int i = 0; i < N - 1; ++i) {
int a = A[i], b = B[i];
adj[a].push_back(b);
adj[b].push_back(a);
}
dfs(0, -1);
}
#include "Device.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 250005;
void InitDevice(){
}
int Answer(ll S, ll T){
ll sta = S / MAXN, ena = S % MAXN, stb = T / MAXN, enb = T % MAXN;
if (sta >= stb && ena <= enb) return 0;
else if (stb >= sta && enb <= ena) return 1;
return 2;
}