#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
const int NQ = 4e5 + 10;
const int LOGN = 20;
struct query {
  int s, k, id;
  query(int s = 0, int k = 0, int id = 0) : s(s), k(k), id(id) {}
};
int n, ne, nq, logn;
vector<int> g[N], grev[N], arc[N];
vector<query> queryAt[N];
int depth[N];
int answer[NQ];
bool was[N];
int dad[N][LOGN];
void dfsRev(int foo) {
  was[foo] = 1;
  for (int bar : grev[foo]) {
    if (not was[bar]) {
      dfsRev(bar);
    }
  }
}
void dfs(int foo, int parent) {
  was[foo] = 1;
  dad[foo][0] = parent;
  depth[foo] = depth[parent] + 1;
  for (int i = 1; i <= logn; i++) dad[foo][i] = dad[dad[foo][i - 1]][i - 1];
  for (int bar : arc[foo]) {
    if (bar == parent || was[bar]) continue;
    dfs(bar, foo);
  }
}
void solve(int root) {
  for (int foo = 1; foo <= n; foo++) was[foo] = 0;
  dfsRev(root);
  for (int foo = 1; foo <= n; foo++) arc[foo].clear();
  for (int foo = 1; foo <= n; foo++) {
    if (foo == root) continue;
    for (int bar : g[foo]) {
      if (was[foo] && was[bar]) {
        arc[bar].push_back(foo);
        break;
      }
    }
  }
  for (int foo = 1; foo <= n; foo++) was[foo] = 0;
  for (int foo = 1; foo <= n; foo++) {
    for (int i = 0; i <= logn; i++) dad[foo][i] = 0;
  }
  dfs(root, 0);
  for (auto q : queryAt[root]) {
    int s = q.s;
    int k = q.k;
    int iq = q.id;
    if (not was[s] || k > depth[s]) {
      answer[iq] = -1;
    } else {
      k--;
      answer[iq] = s;
      for (int i = logn; i >= 0; i--)
        if ((k >> i) & 1) {
          answer[iq] = dad[answer[iq]][i];
        }
    }
  }
}
int main() {
  ios ::sync_with_stdio(false);
  cin >> n >> ne >> nq;
  for (logn = 0; (1 << logn) <= n; logn++)
    ;
  for (int ie = 1; ie <= ne; ie++) {
    int foo, bar;
    cin >> foo >> bar;
    g[foo].push_back(bar);
    grev[bar].push_back(foo);
  }
  for (int foo = 1; foo <= n; foo++) sort(g[foo].begin(), g[foo].end());
  for (int iq = 1; iq <= nq; iq++) {
    int s, t, k;
    cin >> s >> t >> k;
    queryAt[t].push_back(query(s, k, iq));
  }
  for (int root = 1; root <= n; root++) {
    if (queryAt[root].empty()) continue;
    solve(root);
  }
  for (int iq = 1; iq <= nq; iq++) {
    cout << answer[iq] << '\n';
  }
}
