#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000 + 5;
int n, m, q;
vector<int> head[MAXN], G[MAXN];
int st[MAXN][13];
struct node {
  int s, k, id;
};
vector<node> ask[MAXN];
bool vis[MAXN];
void dfs(int u) {
  vis[u] = 1;
  for (int v : G[u])
    if (!vis[v]) dfs(v);
}
int ans[400005];
int main() {
  scanf("%d%d%d", &n, &m, &q);
  int u, v;
  while (m--) {
    scanf("%d%d", &u, &v);
    head[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) sort(head[i].begin(), head[i].end());
  int s, t, k;
  for (int i = 0; i < q; ++i) {
    scanf("%d%d%d", &s, &t, &k);
    ask[t].push_back(node{s, k, i});
  }
  for (int t = 1; t <= n; ++t) {
    if (ask[t].size() == 0) continue;
    fill(vis + 1, vis + 1 + n, 0);
    dfs(t);
    memset(st, 0, sizeof st);
    st[n + 1][0] = n + 1;
    for (int u = 1; u <= n; ++u) {
      if (u == t)
        st[u][0] = n + 1;
      else if (vis[u]) {
        for (int v : head[u]) {
          if (!vis[v]) continue;
          st[u][0] = v;
          break;
        }
      }
    }
    for (int i = 1; i <= 12; ++i)
      for (int j = 1; j <= n + 1; ++j) st[j][i] = st[st[j][i - 1]][i - 1];
    for (node x : ask[t]) {
      int s = x.s;
      int k = x.k - 1;
      int id = x.id;
      if (st[s][12] == n + 1) {
        for (int i = 0; i <= 12; ++i) {
          if (k & (1 << i)) s = st[s][i];
        }
        if (s != n + 1)
          ans[id] = s;
        else
          ans[id] = -1;
      } else
        ans[id] = -1;
    }
  }
  for (int i = 0; i < q; ++i) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
