#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005, maxk = 400005, inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
const long double pi = acos(-1.0L);
int head[maxn], ans[maxk], dfn[maxn], low[maxn];
bool inst[maxn];
vector<int> v[maxn], c[maxn];
int st[maxn], top, s, t;
int num;
struct query {
  int id, x, y, k;
};
query q[maxk];
bool cmp(query a, query b) { return a.x < b.x; }
void tarjan(int now, int step, bool cyc) {
  num++;
  dfn[now] = num;
  low[now] = inf;
  inst[now] = 1;
  st[++top] = now;
  if (cyc) {
    for (int i = 0; i < c[now].size(); i++)
      if (q[c[now][i]].k <= step) ans[q[c[now][i]].id] = st[q[c[now][i]].k];
  }
  for (int i = 0; i < v[now].size(); i++) {
    int to = v[now][i];
    if (!dfn[to]) {
      tarjan(to, step + 1, cyc && dfn[now] < low[now]);
      low[now] = min(low[now], low[to]);
    } else if (inst[to])
      low[now] = min(low[now], dfn[to]);
  }
  inst[now] = 0;
  top--;
}
int main() {
  int n, m, k, i, j, x, y;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
  }
  for (i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
  for (i = 1; i <= k; i++) {
    scanf("%d%d%d", &q[i].x, &q[i].y, &q[i].k);
    q[i].id = i;
  }
  sort(q + 1, q + k + 1, cmp);
  memset(ans, -1, sizeof(ans));
  num = 0;
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  memset(inst, 0, sizeof(inst));
  m = 1;
  for (i = 1; i <= n; i++) {
    if (q[m].x == i) {
      num = top = 0;
      while (q[m].x == i && m <= k) {
        c[q[m].y].push_back(m);
        m++;
      }
      memset(dfn, 0, sizeof(dfn));
      memset(low, 0, sizeof(low));
      memset(inst, 0, sizeof(inst));
      tarjan(i, 1, 1);
      for (j = 1; j <= n; j++) c[j].clear();
    }
  }
  for (i = 1; i <= k; i++) printf("%d\n", ans[i]);
  return 0;
}
