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
#include <iostream>
#include <vector>
#include <queue>
#include <memory.h>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int maxn = 100010;

ll dist[maxn];
vector<P> G[maxn];

vector<ll> bfs(){
  queue<ll> que;
  vector<ll> res;
  memset(dist, -1, sizeof(dist));
  dist[0] = 0;
  que.push(0);
  
  while(!que.empty()){
    int v = que.front(); que.pop();
    rep(i, (int)G[v].size()){
      int to = G[v][i].first;
      ll cost = G[v][i].second;
      if(dist[to] == -1){
	dist[to] = dist[v] ^ cost;
	que.push(to);
      }else{
	if(dist[to] ^ dist[v] ^ cost) res.push_back(dist[to] ^ dist[v] ^ cost);
      }
    }
  }
  return res;
}

vector<ll> collect(vector<ll> cycle){
  int n = cycle.size();
  vector<ll> res(60, 0);
  for(int i = 59; i >= 0; i--){
    rep(j, n){
      if((cycle[j] >> i) & 1){
	res[i] = cycle[j];
	rep(k, n){
	  if(k != j && ((cycle[k] >> i) & 1)) cycle[k] ^= cycle[j];
	}
	cycle[j] = 0;
	break;
      }
    }
  }
  return res;
}

ll calc(ll res, const vector<ll> &base){
  for(int i = 59; i >= 0; i--){
    if(((base[i] ^ res) >> i) & 1) res ^= base[i]; 
  }
  return res;
}

int main(){
  ll N, M, Q, a, b, f, t, p;
  
  cin >> N >> M >> Q;
  rep(i, M) {
    cin >> f >> t >> p;
    G[f].push_back(P(t, p));
    G[t].push_back(P(f, p));
  }
  
  vector<ll> cycle = bfs();
  vector<ll> base = collect(cycle);
  
  rep(i, Q){
    cin >> a >> b;
    cout << calc(dist[a] ^ dist[b], base) << endl;
  }
  return 0;
}