#include <bits/stdc++.h>
using namespace std;
list<int> l[3010];
int c[3010][3010];
int ti;
int b[3010];
int d[3010][3010];
int start;
void dfs(int x) {
  b[x] = 1;
  c[start][x] = 1;
  for (auto v : l[x])
    if (!b[v]) dfs(v);
}
struct p {
  int x, y, k, id;
};
p a[400010];
int ans[400010];
int cmp(p a, p b) { return a.y < b.y; }
list<int> l2[3010];
list<int> l3[3010];
int e[3010];
int st[3010];
void dfs2(int x, int d) {
  st[d] = x;
  for (auto v : l3[x])
    if (a[v].k <= d) ans[a[v].id] = st[d - a[v].k + 1];
  b[x] = 1;
  for (auto v : l2[x])
    if (!b[v]) dfs2(v, d + 1);
}
int main() {
  memset(c, 0, sizeof c);
  memset(d, 0, sizeof d);
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  int i;
  int x, y;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    l[x].push_back(y);
  }
  for (i = 1; i <= n; i++) {
    start = i;
    memset(b, 0, sizeof b);
    dfs(i);
  }
  int j;
  for (i = 1; i <= n; i++)
    for (auto v : l[i])
      for (j = 1; j <= n; j++)
        if (c[v][j])
          if (!d[i][j] || v < d[i][j]) d[i][j] = v;
  for (i = 1; i <= q; i++) {
    scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].k);
    a[i].id = i;
  }
  sort(a + 1, a + q + 1, cmp);
  int k;
  memset(ans, -1, sizeof ans);
  for (i = 1; i <= q; i++)
    if (i == 1 || a[i].y != a[i - 1].y) {
      k = i;
      while (k < q && a[k].y == a[k + 1].y) k++;
      for (j = 1; j <= n; j++) {
        l2[j].clear();
        l3[j].clear();
      }
      for (j = 1; j <= n; j++)
        if (d[j][a[i].y]) l2[d[j][a[i].y]].push_back(j);
      for (j = i; j <= k; j++) l3[a[j].x].push_back(j);
      memset(b, 0, sizeof b);
      dfs2(a[i].y, 1);
    }
  for (i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}
