n, k, Q_ = map(int, input().split()) ab = [] P = list(range(n)) for _ in range(k): a, b = map(int, input().split()) a -= 1 b -= 1 ab.append((a, b)) P[a], P[b] = P[b], P[a] X = [0] * Q_ L = [[] for _ in range(k)] R = [[] for _ in range(k)] for i in range(Q_): l, r, x = map(int, input().split()) l -= 1 r -= 1 x -= 1 X[i] = x L[l].append(i) R[r].append(i) Q = [0] * n for i, p in enumerate(P): Q[p] = i ans = [0] * Q_ for i in range(k - 1, -1, -1): for j in R[i]: x = X[j] X[j] = P[x] a, b = ab[i] P[a], P[b] = P[b], P[a] a = P[a] b = P[b] Q[a], Q[b] = Q[b], Q[a] for j in L[i]: x = X[j] ans[j] = Q[x] + 1 print(*ans, sep="\n")