#include <bits/stdc++.h>
using namespace std;
const int M = 4e5 + 5;
int ans[M];
int s[M];
int t[M];
int k[M];
const int N = 3e3 + 5;
vector<int> queries[N][N];
vector<int> Graph[N];
int visited[N];
vector<int> current_path;
int cycle_head = 0;
int disc[N];
int tt = 0;
void dfs(int u, int source) {
  visited[u] = 1;
  current_path.push_back(u);
  disc[u] = ++tt;
  for (auto q : queries[source][u]) {
    if (k[q] <= current_path.size() && !cycle_head) {
      ans[q] = current_path[k[q] - 1];
    }
  }
  for (auto v : Graph[u]) {
    if (!visited[v])
      dfs(v, source);
    else if (visited[v] == 1 && disc[v] < disc[cycle_head])
      cycle_head = v;
  }
  current_path.pop_back();
  if (cycle_head == u) cycle_head = 0;
  visited[u] = 2;
}
int main() {
  disc[0] = 1e9;
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    Graph[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) sort(Graph[i].begin(), Graph[i].end());
  for (int i = 1; i <= q; i++) {
    scanf("%d %d %d", s + i, t + i, k + i);
    queries[s[i]][t[i]].push_back(i);
    ans[i] = -1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) visited[j] = 0;
    dfs(i, i);
  }
  for (int i = 1; i <= q; i++) {
    printf("%d\n", ans[i]);
  }
}
