#include <bits/stdc++.h>
using namespace std;
int f[3009][3009];
vector<int> v[3009], w[3009];
vector<pair<int, int> > Q[3009][3009];
void dfs(int x, int st) {
  f[st][x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (f[st][v[x][i]] == 0) dfs(v[x][i], st);
  }
}
vector<int> cur;
int ans[400009];
void dfs1(int x, int T) {
  cur.push_back(x);
  for (int i = 0; i < Q[x][T].size(); i++) {
    int c = Q[x][T][i].second;
    if (Q[x][T][i].first > cur.size()) {
      ans[c] = -1;
    } else {
      ans[c] = cur[cur.size() - Q[x][T][i].first];
    }
  }
  for (int i = 0; i < w[x].size(); i++) {
    dfs1(w[x][i], T);
  }
  cur.pop_back();
}
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    sort(v[i].begin(), v[i].end());
    dfs(i, i);
  }
  for (int i = 0; i < q; i++) {
    int s, t, k;
    cin >> s >> t >> k;
    Q[s][t].push_back({k, i});
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      w[j].clear();
    }
    for (int j = 1; j <= n; j++) {
      if (j == i) continue;
      for (int x = 0; x < v[j].size(); x++) {
        if (f[v[j][x]][i]) {
          w[v[j][x]].push_back(j);
          break;
        }
      }
    }
    dfs1(i, i);
  }
  for (int i = 0; i < q; i++)
    if (ans[i] == 0)
      printf("-1\n");
    else
      printf("%d\n", ans[i]);
}
