#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
int Begin[maxn], to[maxn << 1], Next[maxn << 1], e;
short f[maxn][maxn][13];
bool p[maxn][maxn];
int n, m, q_cnt;
void add_edge(int u, int v) { to[++e] = v, Next[e] = Begin[u], Begin[u] = e; }
void dfs(int st, int u) {
  if (p[st][u]) return;
  p[st][u] = 1;
  for (int i = Begin[u]; i; i = Next[i]) dfs(st, to[i]);
}
void get_f(int u, int v) {
  int res = n + 1;
  for (int i = Begin[u]; i; i = Next[i])
    if (p[to[i]][v]) res = min(res, to[i]);
  f[u][v][0] = res <= n ? res : 0;
}
int find_kth(int u, int v, int k) {
  int t = u;
  for (int i = 12, iend = 0; i >= iend; --i)
    if (f[t][v][i]) t = f[t][v][i];
  if (t != v) return -1;
  for (int i = 12, iend = 0; i >= iend; --i)
    if ((1 << i) <= k) u = f[u][v][i], k -= (1 << i);
  return u == 0 ? -1 : u;
}
int main() {
  scanf("%d%d%d", &n, &m, &q_cnt);
  for (int i = 1, iend = m; i <= iend; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    add_edge(u, v);
  }
  for (int i = 1, iend = n; i <= iend; ++i) dfs(i, i);
  for (int i = 1, iend = n; i <= iend; ++i)
    for (int j = 1, jend = n; j <= jend; ++j)
      if (i != j) get_f(i, j);
  for (int k = 1, kend = 12; k <= kend; ++k)
    for (int i = 1, iend = n; i <= iend; ++i)
      for (int j = 1, jend = n; j <= jend; ++j)
        f[i][j][k] = f[f[i][j][k - 1]][j][k - 1];
  for (int i = 1, iend = q_cnt; i <= iend; ++i) {
    int u, v, k;
    scanf("%d%d%d", &u, &v, &k);
    printf("%d\n", find_kth(u, v, k - 1));
  }
  return 0;
}
