#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
vector<int> flist[maxn], rlist[maxn], clist[maxn];
int n, m, q;
int component[maxn], cptr = 0;
int visited[maxn];
stack<int> etime;
void fdfs(int cur, vector<int> adj[]) {
  visited[cur] = 1;
  for (auto u : adj[cur]) {
    if (visited[u] != 1) fdfs(u, adj);
  }
  etime.push(cur);
}
void rdfs(int cur, vector<int> adj[]) {
  visited[cur] = 1;
  component[cur] = cptr;
  for (auto u : adj[cur]) {
    if (visited[u] != 1) rdfs(u, adj);
  }
}
void kosaraju() {
  for (int i = 1; i < maxn; i++) {
    if (visited[i] != 1) fdfs(i, flist);
  }
  memset(visited, 0, sizeof(visited));
  while (!etime.empty()) {
    int cur = etime.top();
    etime.pop();
    if (visited[cur] == 1) continue;
    cptr++;
    rdfs(cur, rlist);
  }
}
struct query {
  int u, v, k, id, ans;
};
bool ucomp(query a, query b) { return a.u < b.u; }
bool idcomp(query a, query b) { return a.id < b.id; }
int done[maxn];
const int logN = 13;
int parent[maxn][logN], depth[maxn];
void buildLCA() {
  for (long long j = 1; j < logN; j++) {
    for (long long i = 1; i <= n; i++) {
      if (parent[i][j - 1] != 0) {
        parent[i][j] = parent[parent[i][j - 1]][j - 1];
      }
    }
  }
}
int getNode(int u, int p) {
  if (p < 0 || parent[u][0] == 0 || visited[u] == 0) return -1;
  for (int i = logN - 1; i >= 0; i--) {
    int shift = 1 << i;
    if (shift <= p) {
      p -= shift;
      u = parent[u][i];
    }
  }
  return (u == 0 ? -1 : u);
}
void remove(int cur) {
  visited[cur] = 1;
  for (auto u : flist[cur]) {
    if (visited[u]) continue;
    remove(u);
  }
}
void ddffss(int cur) {
  visited[cur] = 1;
  for (int i = 0; i < flist[cur].size(); i++) {
    int u = flist[cur][i];
    if (visited[u]) continue;
    if (i >= clist[cur].size()) {
      remove(u);
      continue;
    }
    parent[u][0] = cur;
    depth[u] = 1 + depth[cur];
    ddffss(u);
  }
}
void prep(int cur) {
  memset(visited, 0, sizeof(visited));
  memset(parent, 0, sizeof(parent));
  memset(depth, 0, sizeof(depth));
  ddffss(cur);
  buildLCA();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> m >> q;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    flist[u].push_back(v);
    rlist[v].push_back(u);
  }
  kosaraju();
  for (int i = 1; i <= n; i++) sort(flist[i].begin(), flist[i].end());
  for (int i = 1; i <= n; i++) {
    for (auto u : flist[i]) {
      clist[i].push_back(u);
      if (component[i] == component[u]) {
        break;
      }
    }
  }
  query Q[q];
  for (int i = 0; i < q; i++) {
    cin >> Q[i].u >> Q[i].v >> Q[i].k;
    Q[i].id = i;
  }
  sort(Q, Q + q, ucomp);
  for (int i = 0; i < q; i++) {
    if (done[Q[i].u] == 0) prep(Q[i].u);
    done[Q[i].u] = 1;
    Q[i].ans = getNode(Q[i].v, depth[Q[i].v] + 1 - Q[i].k);
  }
  sort(Q, Q + q, idcomp);
  for (int i = 0; i < q; i++) {
    cout << Q[i].ans << '\n';
  }
  return 0;
}
