#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3001, MAXQ = 4e5;
int N, M, Q;
bool done;
vector<int> G[MAXN], V;
vector<pair<int, int> > Qu[MAXN][MAXN];
int ans[MAXQ], vis[MAXN], cnt[MAXN], cc = 0;
void dfs(int v, int s) {
  V.push_back(v);
  vis[v] = 1;
  if (cc == 0) {
    for (int i = 0; i < (int)Qu[s][v].size(); i++) {
      int d = Qu[s][v][i].first;
      int id = Qu[s][v][i].second;
      if (d < V.size()) ans[id] = V[d] + 1;
    }
  }
  for (int u : G[v]) {
    if (vis[u] == 0)
      dfs(u, s);
    else if (vis[u] == 1) {
      cnt[u]--;
      cc++;
    }
  }
  cc += cnt[v];
  vis[v] = 2;
  V.pop_back();
}
int main() {
  scanf("%d", &N), scanf("%d", &M), scanf("%d", &Q);
  for (int i = 0; i < (int)M; i++) {
    int v, u;
    scanf("%d", &v), scanf("%d", &u);
    v--, u--;
    G[v].push_back(u);
  }
  for (int v = 0; v < (int)N; v++) sort(G[v].begin(), G[v].end());
  for (int q = 0; q < (int)Q; q++) {
    int s, t, k;
    scanf("%d", &s), scanf("%d", &t), scanf("%d", &k);
    s--, t--, k--;
    Qu[s][t].push_back({k, q});
  }
  memset(ans, -1, sizeof(ans));
  for (int i = 0; i < (int)N; i++) {
    memset(vis, 0, sizeof(vis));
    memset(cnt, 0, sizeof(cnt));
    done = false;
    dfs(i, i);
  }
  for (int i = 0; i < (int)Q; i++) printf("%d\n", ans[i]);
}
