#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n, m, q;
vector<int> adj[N];
int ex[N];
int bl[N][15];
int vis[N];
bool bad[N];
void mark(int i) {
  if (vis[i] == 3) return;
  vis[i] = 3;
  if (vis[i] == 0) bad[i] = true;
  for (int j : adj[i]) {
    mark(j);
  }
}
void dfs(int i, int p, int curr) {
  vis[i] = 1;
  ex[i] = curr;
  if (p != i) {
    bl[i][0] = p;
    for (int j = 1; j < 15; j++) {
      bl[i][j] = bl[bl[i][j - 1]][j - 1];
    }
  }
  for (int j : adj[i]) {
    if (vis[j] == 2 || vis[j] == 3) continue;
    if (vis[j] == 1) {
      mark(j);
      continue;
    }
    dfs(j, i, curr + 1);
  }
  vis[i] = 2;
}
int get(int i, int j) {
  for (int k = 14; k >= 0; k--) {
    if (j >= pow(2, k)) {
      j -= pow(2, k);
      i = bl[i][k];
    }
  }
  return i;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> q;
  while (m--) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) sort(adj[i].begin(), adj[i].end());
  vector<pair<int, pair<pair<int, int>, int>>> v;
  for (int lol = 0; lol < q; lol++) {
    int s, t, k;
    cin >> s >> t >> k;
    v.push_back({s, {{t, k}, lol}});
  }
  sort(v.begin(), v.end());
  int curr = 0;
  int ans[q];
  for (pair<int, pair<pair<int, int>, int>> x : v) {
    int s = x.first, t = x.second.first.first, k = x.second.first.second,
        ind = x.second.second;
    if (s > curr) {
      curr = s;
      for (int j = 1; j <= n; j++) {
        vis[j] = 0;
        ex[j] = 0;
        bad[j] = false;
        for (int xx = 0; xx < 15; xx++) bl[j][xx] = 0;
      }
      dfs(s, s, 1);
    }
    if (ex[t] < k || bad[t]) {
      ans[ind] = -1;
      continue;
    }
    int ab = ex[t] - k;
    ans[ind] = get(t, ab);
  }
  for (int i = 0; i < q; i++) cout << ans[i] << endl;
  return 0;
}
