#include <bits/stdc++.h>
using namespace std;
int vis[400000], cur, path[500000], block[500000], x, y, n, m, q, k, s, t,
    seen[400010], ans[400010];
vector<int> g[4000];
map<pair<int, int>, vector<pair<int, int> > > M;
void color(int x) {
  if (block[x]) return;
  block[x] = 1;
  for (int i = 0; i < g[x].size(); i++) color(g[x][i]);
}
void dfs(int x, int dep) {
  if (vis[x]) {
    int now = dep - 1;
    while (path[now] != x && now > 0) color(path[now--]);
    color(path[now]);
  }
  if (seen[x]) return;
  path[dep] = x;
  vis[x] = seen[x] = 1;
  if (M.find(make_pair(cur, x)) != M.end()) {
    if (!block[x]) {
      vector<pair<int, int> > tmp = M[make_pair(cur, x)];
      for (int i = 0; i < tmp.size(); i++)
        if (tmp[i].first <= dep) ans[tmp[i].second] = path[tmp[i].first];
    }
  }
  for (int i = 0; i < g[x].size(); i++) dfs(g[x][i], dep + 1);
  vis[x] = 0;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) sort(g[i].begin(), g[i].end());
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d", &s, &t, &k);
    M[make_pair(s, t)].push_back(make_pair(k, i));
  }
  memset(ans, 0xff, sizeof(ans));
  for (int i = 1; i <= n; i++) {
    cur = i;
    memset(seen, 0, sizeof(seen));
    memset(block, 0, sizeof(block));
    dfs(i, 1);
  }
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}
