#include <bits/stdc++.h>
using namespace std;
int n, m, q, i, ans[400010], dp[15][3010], in, dr, ind, x, y, a, b, c, j, k;
vector<int> g[3010];
vector<pair<pair<int, int>, int> > v[3010];
void dfs(int node, int x) {
  for (auto &it : g[node])
    if (!dp[0][it] || dp[0][it] > node)
      if (it != x) {
        dp[0][it] = node;
        dfs(it, x);
      }
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    g[y].push_back(x);
  }
  for (i = 1; i <= q; ++i) {
    scanf("%d%d%d", &a, &b, &c);
    v[b].push_back({{a, c}, i});
  }
  for (i = 1; i <= n; ++i)
    if (v[i].size() > 0) {
      memset(dp[0], 0, sizeof(dp[0]));
      dfs(i, i);
      for (in = 1; in <= 12; ++in)
        for (j = 1; j <= n; ++j) dp[in][j] = dp[in - 1][dp[in - 1][j]];
      for (j = 0; j < v[i].size(); ++j) {
        in = v[i][j].first.first;
        dr = v[i][j].first.second - 1;
        ind = v[i][j].second;
        if (!dp[0][in] || dp[12][in]) {
          ans[ind] = -1;
          continue;
        }
        k = 0;
        while (dr != 0) {
          if (dr % 2 == 1) in = dp[k][in];
          ++k;
          dr /= 2;
        }
        ans[ind] = in;
        if (ans[ind] == 0) ans[ind] = -1;
      }
    }
  for (i = 1; i <= q; ++i) printf("%d\n", ans[i]);
  return 0;
}
