#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
map<pair<int, int>, vector<pair<int, int> > > queries;
vector<int> e[N];
int n, m, q;
int ans[400010];
int flag[N], loop[N];
int total_loop;
void dfs(int start, int x, vector<int> &route) {
  route.push_back(x);
  flag[x] = 1;
  pair<int, int> key = pair<int, int>(start, x);
  if (!total_loop and queries.count(key)) {
    vector<pair<int, int> > tasks = queries[key];
    for (int i = 0; i < tasks.size(); ++i) {
      int k = tasks[i].first, idx = tasks[i].second;
      if (k <= route.size()) ans[idx] = route[k - 1];
    }
  }
  for (int i = 0; i < e[x].size(); ++i) {
    int y = e[x][i];
    if (!flag[y]) {
      dfs(start, y, route);
    } else if (flag[y] == 1) {
      loop[y]++;
      total_loop++;
    }
  }
  route.pop_back();
  total_loop -= loop[x];
  flag[x] = 2;
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0, x, y; i < m; ++i) {
    scanf("%d %d", &x, &y);
    e[x].push_back(y);
  }
  for (int i = 1; i <= n; ++i) sort(e[i].begin(), e[i].end());
  for (int i = 0, x, y, k; i < q; ++i) {
    scanf("%d %d %d", &x, &y, &k);
    queries[pair<int, int>(x, y)].push_back(pair<int, int>(k, i));
  }
  memset(ans, -1, sizeof(ans));
  for (int i = 1; i <= n; ++i) {
    vector<int> route;
    memset(flag, 0, sizeof(flag));
    memset(loop, 0, sizeof(loop));
    total_loop = 0;
    dfs(i, i, route);
  }
  for (int i = 0; i < q; ++i) printf("%d\n", ans[i]);
  return 0;
}
