#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e3 + 5;
const int MAX_Q = 4e5 + 5;
const int INF = 0x3f3f3f3f;
struct Query {
  int id, s, t, k;
  Query() {}
  Query(int i_, int s_, int t_, int k_) : id(i_), s(s_), t(t_), k(k_) {}
  bool operator<(const Query &rhs) const { return t < rhs.t; }
};
int N, M, Q;
vector<int> G[MAX_N];
vector<int> rG[MAX_N];
Query query[MAX_Q];
int ans[MAX_Q];
bool vis[MAX_N];
bool canto[MAX_N][MAX_N];
int nxt[MAX_N][MAX_N];
vector<int> queryList[MAX_N];
int path[MAX_N];
void addEdge(int s, int t) { G[s].push_back(t); }
void addREdge(int s, int t) { rG[s].push_back(t); }
void dfs(int start, int v) {
  vis[v] = true;
  canto[start][v] = true;
  for (int u : G[v]) {
    if (!vis[u]) dfs(start, u);
  }
}
void dfs2(int v, int dep) {
  vis[v] = true;
  path[dep] = v;
  for (int q : queryList[v]) {
    if (dep - query[q].k + 1 >= 0) {
      ans[query[q].id] = path[dep - query[q].k + 1] + 1;
    }
  }
  for (int u : rG[v]) {
    if (!vis[u]) dfs2(u, dep + 1);
  }
}
void solve() {
  for (int i = 0; i < N; ++i) {
    memset(vis, 0, sizeof vis);
    dfs(i, i);
  }
  memset(nxt, 0x3f, sizeof nxt);
  for (int i = 0; i < N; ++i) {
    for (int j : G[i]) {
      for (int k = 0; k < N; ++k) {
        if (canto[j][k]) {
          nxt[i][k] = min(j, nxt[i][k]);
        }
      }
    }
  }
  memset(ans, -1, sizeof ans);
  sort(query, query + Q);
  for (int q = 0, qr = q; q < Q; q = qr) {
    while (qr < Q && query[qr].t == query[q].t) ++qr;
    for (int i = 0; i < N; ++i) {
      rG[i].clear();
      queryList[i].clear();
    }
    int t = query[q].t;
    for (int i = 0; i < N; ++i) {
      if (nxt[i][t] != INF) {
        addREdge(nxt[i][t], i);
      }
    }
    for (int i = q; i < qr; ++i) {
      queryList[query[i].s].push_back(i);
    }
    memset(vis, 0, sizeof vis);
    dfs2(t, 0);
  }
  for (int i = 0; i < Q; ++i) {
    cout << ans[i] << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M >> Q;
  for (int i = 0; i < M; ++i) {
    int s, t;
    cin >> s >> t;
    --s;
    --t;
    addEdge(s, t);
  }
  for (int i = 0; i < Q; ++i) {
    int s, t, k;
    cin >> s >> t >> k;
    --s;
    --t;
    query[i] = Query(i, s, t, k);
  }
  solve();
  return 0;
}
