#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
const int inf = 1e6;
int st[maxn], vis[maxn], res[400010], dfn[maxn], instk[maxn], low[maxn];
struct node {
  int id, from, to, k;
  node() {}
  node(int a, int d, int b, int c) { id = a, from = d, to = b, k = c; }
};
node qs[400010];
vector<int> v[maxn];
vector<node> Q[maxn];
bool cmp(node a1, node a2) {
  if (a1.from != a2.from)
    return a1.from < a2.from;
  else
    return a1.to < a2.to;
}
int tot = 0, flag = 0, top = 0;
void dfs(int u, int ok) {
  dfn[u] = ++top;
  low[u] = inf;
  st[++tot] = u;
  instk[u] = 1;
  if (ok) {
    for (int i = 0; i < Q[u].size(); i++) {
      node t = Q[u][i];
      if (t.k <= tot) res[t.id] = st[t.k];
    }
  }
  for (int i = 0; i < v[u].size(); i++) {
    if (flag == 1) return;
    int t = v[u][i];
    if (!dfn[t]) {
      dfs(t, ok && dfn[u] < low[u]);
      low[u] = min(low[u], low[t]);
    } else if (instk[t])
      low[u] = min(low[u], dfn[t]);
  }
  instk[u] = 0;
  --tot;
}
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  memset(res, -1, sizeof(res));
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    v[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
  for (int i = 1; i <= q; i++) {
    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);
    node t;
    t.id = i;
    t.from = a;
    t.to = b;
    t.k = k;
    qs[i] = t;
  }
  sort(qs + 1, qs + q + 1, cmp);
  for (int i = 1; i <= q; i++) {
    Q[qs[i].to].push_back(qs[i]);
    if (qs[i].from != qs[i + 1].from) {
      memset(dfn, 0, sizeof(dfn));
      memset(st, 0, sizeof(st));
      memset(low, 0, sizeof(low));
      memset(instk, 0, sizeof(instk));
      vis[qs[i].from] = 1;
      tot = 0, flag = 0, top = 0;
      dfs(qs[i].from, 1);
      for (int j = 1; j <= n; j++) Q[j].clear();
    }
  }
  for (int i = 1; i <= q; i++) printf("%d\n", res[i]);
  return 0;
}
