#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);
	}
}