#include <bits/stdc++.h>
using namespace std;
void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
const int N = 3010;
int n, m, q, cyc[N], ans[4 * (int)1e5 + 5], dep[N];
vector<int> child[N], pom;
int vis[N];
vector<pair<int, int> > query[N][N];
void jebaj(int v) {
  for (int dz : child[v])
    if (vis[dz] != 2) {
      vis[dz] = 2;
      jebaj(dz);
    }
}
void dfs(int v, int beg, int depth, vector<int>& nodes) {
  vis[v] = 1;
  nodes.push_back(v);
  dep[v] = depth;
  if (query[beg][v].size() > 0)
    for (pair<int, int> p : query[beg][v])
      if (nodes.size() >= p.second) ans[p.first] = nodes[p.second - 1];
  for (int x : child[v]) {
    if (vis[x] == 0)
      dfs(x, beg, depth + 1, nodes);
    else if (vis[x] == 2)
      continue;
    else
      for (int i = dep[x]; i <= depth; ++i) jebaj(nodes[i]);
  }
  nodes.pop_back();
  vis[v] = 2;
}
int main() {
  init_ios();
  cin >> n >> m >> q;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    child[x].push_back(y);
  }
  for (int i = 1; i <= q; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    query[a][b].push_back({i, c});
    ans[i] = -1;
  }
  for (int i = 1; i <= n; ++i) sort(child[i].begin(), child[i].end());
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) vis[j] = 0;
    dfs(i, i, 0, pom);
  }
  for (int i = 1; i <= q; ++i) cout << ans[i] << "\n";
}
