Problem statement

An unusual rally game is popular at KU University. The circuit, which is the setting of this game, has N rest areas and M roads, and the i-th road is between the fi-th rest area and the ti-th rest area. There is one checkpoint on every road, and if you pass the checkpoint on road i, the score of pi will be added by XOR regardless of which direction you pass. It is added by XOR. I said it twice because it's important.

In this game, you can go through the same resting place or road as many times as you like, and even if you reach the goal, you can continue the rally as it is, but you can bypass the checkpoint in the middle of the road and go to another resting place. That is forbidden. Therefore, the reason why it is so popular is that you have to work hard to think about what kind of route you should take to get a high score.

There are Q participants this time, and it seems that the jth participant is supposed to start from the resting place of aj and go to the resting place of bj which is the goal. As a person on the management side, I decided to check the highest score of each participant in advance.

Input format

The input is given in the following format. The rest area number is 0-indexed.


N M Q
f1 t1 p1
...
fM tM pM
a1 b1
...
aQ bQ


Output format

Output the Q line, and output the maximum score obtained by the route from the ajth resting place to the bjth resting place on the jth line.

Constraint

* 1 ≤ N ≤ 105
* 0 ≤ M ≤ 2 × 105
* 1 ≤ Q ≤ 105
* 0 ≤ fi, ti <N, fi ≠ ti
* 0 ≤ pi <260
* 0 ≤ aj, bj <N
* From any resting place, you can reach any resting place by following the road.
* There is at most one road connecting the rest areas fi and ti.
* All input values ​​are integers.



A group of 60 test cases is set to judge this problem. In addition to the above constraints, the test cases included in this group also meet the following constraints.

* M ≤ 20





Examples

Input

5 5 3
0 1 7
1 2 22
2 3 128
3 4 128
4 2 128
0 1
0 0
3 4


Output

135
128
128


Input

None


Output

None
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
ll INF = LLONG_MAX / 3;
double EPS = 1e-10;

void dfs(int u, vector<vector<edge> >& G, vector<ll>& a) {
	for (int i = 0; i < G[u].size(); i++) {
		edge e = G[u][i];
		if (a[e.v] != -1) continue;
		a[e.v] = a[u] ^ e.w;
		dfs(e.v, G, a);
	}
}

int main() {
	int N, M, Q; cin >> N >> M >> Q;
	vector<vector<edge> > G(N);
	while (M--) {
		int x, y; ll w; scanf("%d%d%lld", &x, &y, &w);
		edge e = {y, w};
		G[x].push_back(e);
		edge _e = {x, w};
		G[y].push_back(_e);
	}
	vector<ll> a(N, -1);
	a[0] = 0;
	dfs(0, G, a);
	vector<ll> b;
	for (int u = 0; u < N; u++)
		for (int i = 0; i < G[u].size(); i++) {
			edge e = G[u][i];
			b.push_back(a[u] ^ a[e.v] ^ e.w);
		}
	int n = b.size(), k = 0;
	for (ll x = 1LL<<60; x; x >>= 1)
		for (int i = k; i < n; i++)
			if (b[i] & x) {
				swap(b[k], b[i]);
				for (int i = k + 1; i < n; i++)
					if (b[i] & x)
						b[i] ^= b[k];
				k++;
				break;
			}
	while (Q--) {
		int x, y; scanf("%d%d", &x, &y);
		ll z = a[x] ^ a[y];
		for (int i = 0; i < k; i++)
			if (z < (z ^ b[i]))
				z ^= b[i];
		printf("%lld\n", z);
	}
}