#include <bits/stdc++.h>
using namespace std;
const int N = 3000 + 5;
const int Q = 400000 + 5;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& c) {
  os << "[";
  for (auto it = begin(c); it != end(c); ++it)
    os << (it == begin(c) ? "" : " ") << *it;
  return os << "]";
}
bool instk[N];
vector<pair<size_t, int> > que[N][N];
vector<int> G[N];
int ans[Q], step[N];
void all_clear(int, int);
void dfs(int, int, vector<int>&);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  memset(ans, -1, sizeof(ans));
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
  }
  for (int i = 1; i <= n; ++i) sort(G[i].begin(), G[i].end());
  for (int i = 0; i < q; ++i) {
    int u, v;
    size_t k;
    cin >> u >> v >> k;
    que[u][v].emplace_back(k, i);
  }
  for (int i = 1; i <= n; ++i) {
    vector<int> tmp;
    dfs(i, i, tmp);
  }
  for (int i = 0; i < q; ++i) cout << ans[i] << '\n';
  return 0;
}
void all_clear(int u, int s) {
  step[u] = s;
  for (int v : G[u])
    if (step[v] != s) all_clear(v, s);
}
void dfs(int u, int s, vector<int>& stk) {
  if (instk[u]) {
    all_clear(u, s);
    return;
  }
  instk[u] = true;
  stk.push_back(u);
  for (auto q : que[s][u])
    ans[q.second] = (q.first > stk.size()) ? -1 : stk[q.first - 1];
  for (int v : G[u])
    if (step[v] != s) dfs(v, s, stk);
  step[u] = s;
  instk[u] = false;
  stk.pop_back();
  return;
}
