#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 3010;
const int maxq = 4e5 + 10;
struct node {
  int id, x, y, k;
  node() {}
  node(int id, int x, int y, int k) : id(id), x(x), y(y), k(k) {}
  bool operator<(const node &rhs) const { return x < rhs.x; }
} qs[maxq];
vector<node> Q[maxn];
int n, m, q, ans[maxq];
int dfsclk, top;
int dfn[maxn], low[maxn], instk[maxn], stk[maxn];
vector<int> G[maxn];
void dfs(int u, int ok) {
  dfn[u] = ++dfsclk;
  low[u] = inf;
  stk[top++] = u;
  instk[u] = 1;
  if (ok) {
    for (int i = 0; i < Q[u].size(); i++) {
      if (Q[u][i].k <= top) ans[Q[u][i].id] = stk[Q[u][i].k - 1];
    }
  }
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!dfn[v]) {
      dfs(v, ok && dfn[u] < low[u]);
      low[u] = min(low[u], low[v]);
    } else if (instk[v]) {
      low[u] = min(low[u], dfn[v]);
    }
  }
  instk[u] = 0;
  --top;
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    G[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) sort(G[i].begin(), G[i].end());
  for (int i = 0; i < q; i++) {
    int x, y, k;
    scanf("%d %d %d", &x, &y, &k);
    qs[i] = node(i, x, y, k);
  }
  sort(qs, qs + q);
  memset(ans, -1, sizeof(ans));
  for (int i = 0; i < q; i++) {
    Q[qs[i].y].push_back(qs[i]);
    if (qs[i].x != qs[i + 1].x) {
      memset(dfn, 0, sizeof(dfn));
      memset(instk, 0, sizeof(stk));
      memset(low, 0, sizeof(low));
      top = dfsclk = 0;
      dfs(qs[i].x, 1);
      for (int j = 1; j <= n; j++) Q[j].clear();
    }
  }
  for (int i = 0; i < q; i++) printf("%d\n", ans[i]);
  return 0;
}
