#include <bits/stdc++.h>
using namespace std;
int num;
struct node {
  int s, t, k, id;
} a[400500];
bool cmp(node x, node y) { return x.t < y.t; }
int f[20][3010];
int g[3010], ans[400500];
int vet[3010], Next[3010], hed[3010];
void add(int u, int v) {
  ++num;
  vet[num] = v;
  Next[num] = hed[u];
  hed[u] = num;
}
void dfs(int u, int rt) {
  for (int i = hed[u]; i != -1; i = Next[i]) {
    int v = vet[i];
    if (v == rt) continue;
    if (!g[v] || g[v] > u) g[v] = u, dfs(v, rt);
  }
}
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) hed[i] = -1;
  num = 0;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(v, u);
  }
  for (int i = 1; i <= q; ++i)
    scanf("%d%d%d", &a[i].s, &a[i].t, &a[i].k), a[i].id = i;
  sort(a + 1, a + q + 1, cmp);
  a[0].t = -1;
  for (int i = 1; i <= q; ++i) {
    if (a[i].t != a[i - 1].t) {
      memset(g, 0, sizeof(g));
      dfs(a[i].t, a[i].t);
      for (int j = 1; j <= n; ++j) f[0][j] = g[j];
      for (int j = 1; j <= 15; ++j)
        for (int k = 1; k <= n; ++k) f[j][k] = f[j - 1][f[j - 1][k]];
    }
    if (!g[a[i].s] || f[15][a[i].s]) {
      ans[a[i].id] = -1;
      continue;
    }
    int u = a[i].s;
    int k = a[i].k - 1;
    for (int t = 0; k; ++t, k >>= 1)
      if (k & 1) u = f[t][u];
    if (u != 0)
      ans[a[i].id] = u;
    else
      ans[a[i].id] = -1;
  }
  for (int i = 1; i <= q; ++i) printf("%d\n", ans[i]);
  return 0;
}
