N,K,Q = map(int,input().split()) sousa = [] for _ in range(K): a,b = map(int,input().split()) sousa.append((a-1,b-1)) query = [] right = [] left = [] for _ in range(Q): l,r,x = map(int,input().split()) query.append((l-1,r-1,x-1)) right.append((r - 1,x - 1,_)) left.append((l - 1,x - 1,_)) right.sort() left.sort() P = list(range(N)) inv = list(range(N)) now = 0 sub = [0] * Q for r,x,i in left: while now < r: a,b = sousa[now] inv[P[a]] = b inv[P[b]] = a P[a],P[b] = P[b],P[a] now += 1 sub[i] = P[x] P = list(range(N)) inv = list(range(N)) now = 0 ans = [0] * Q for l,x,i in right: while now <= l: a,b = sousa[now] inv[P[a]] = b inv[P[b]] = a P[a],P[b] = P[b],P[a] now += 1 ans[i] = inv[sub[i]] + 1 for a in ans: print(a)