#include <bits/stdc++.h>
#pragma GCC optimize("O2,unroll-loops")
using namespace std;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 3010, LOG = 20;
int n, m, q, u, v, x, y, t, a, b;
int A[400001], B[400001], K[400001], ans[400001];
bool mark[MAXN][MAXN];
vector<int> G[MAXN], G2[MAXN], Q[MAXN], vec[MAXN], path;
void dfs1(bool *mark, int node) {
  mark[node] = 1;
  for (int v : G[node])
    if (!mark[v]) dfs1(mark, v);
}
void dfs2(int node) {
  path.push_back(node);
  for (int id : vec[node])
    if (K[id] <= path.size()) ans[id] = path[path.size() - K[id]];
  for (int v : G2[node]) dfs2(v);
  path.pop_back();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> q;
  while (m--) {
    cin >> u >> v;
    G[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) dfs1(mark[i], i);
  for (int i = 1; i <= q; i++) {
    cin >> A[i] >> B[i] >> K[i];
    ans[i] = -1;
    Q[B[i]].push_back(i);
  }
  for (int v = 1; v <= n; v++) {
    for (int i = 1; i <= n; i++) vec[i].clear(), G2[i].clear();
    for (int x = 1; x <= n; x++)
      if (mark[x][v] && x != v) {
        int mn = inf;
        for (int y : G[x])
          if (mark[y][v]) mn = min(mn, y);
        G2[mn].push_back(x);
      }
    for (int id : Q[v]) vec[A[id]].push_back(id);
    dfs2(v);
  }
  for (int i = 1; i <= q; i++) cout << ans[i] << "\n";
  return 0;
}
