#include <bits/stdc++.h>
using namespace std;
vector<int> al[3009];
int ans[400009];
int qt[400009], qk[400009];
vector<int> qu[3009];
int vis[3009], disq[3009];
vector<int> stk;
vector<pair<int, int> > pqu[3009];
void dfs2(int v) {
  if (disq[v]) return;
  if (vis[v])
    disq[v] = 1;
  else
    disq[v] = 2;
  for (int i = 0; i < (int)al[v].size(); i++) {
    int u = al[v][i];
    dfs2(u);
  }
}
void dfs(int v) {
  if (vis[v] || disq[v]) return;
  vis[v]++;
  stk.push_back(v);
  for (int i = 0; i < (int)pqu[v].size(); i++) {
    int k = pqu[v][i].first;
    k--;
    if (k < stk.size()) {
      ans[pqu[v][i].second] = stk[k];
    }
  }
  for (int i = 0; i < (int)al[v].size(); i++) {
    int u = al[v][i];
    if (disq[u]) continue;
    if (vis[u] == 2) continue;
    if (vis[u] == 1) {
      dfs2(u);
      continue;
    }
    dfs(u);
  }
  stk.pop_back();
  vis[v]++;
}
int main() {
  int n, m, q;
  scanf("%d %d", &n, &m);
  scanf("%d", &q);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    al[x].push_back(y);
  }
  for (int i = 1; i < n + 1; i++) sort(al[i].begin(), al[i].end());
  for (int i = 0; i < q; i++) {
    int s;
    scanf("%d %d", &s, &qt[i]);
    scanf("%d", &qk[i]);
    qu[s].push_back(i);
    ans[i] = -1;
  }
  for (int i = 1; i < n + 1; i++) {
    stk.clear();
    fill(vis, vis + n + 1, 0);
    fill(disq, disq + n + 1, 0);
    for (int j = 0; j < n + 3; j++) pqu[j].clear();
    for (int j = 0; j < (int)qu[i].size(); j++) {
      int x = qu[i][j];
      pqu[qt[x]].push_back(make_pair(qk[x], x));
    }
    dfs(i);
  }
  for (int i = 0; i < q; i++) {
    printf("%d", ans[i]);
    printf("\n");
  }
}
