#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000000 + 7;
const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const long long infl = 10000000000000000;
const int maxn = 3000 + 10;
const int maxm = 100 + 10;
int in(int &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return -1;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
vector<int> g[maxn];
bool can[maxn][maxn];
short int fa[maxn][maxn][13];
void dfs(int u, int f) {
  if (can[f][u]) return;
  can[f][u] = 1;
  int sz = g[u].size();
  for (int i = 0; i < (sz); ++i) {
    int v = g[u][i];
    dfs(v, f);
  }
}
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
  }
  for (int i = 1; i <= n; ++i) dfs(i, i);
  for (int i = 1; i <= n; ++i) {
    sort(g[i].begin(), g[i].end());
    for (int j = 1; j <= n; ++j) {
      if (j != i) {
        int sz = g[i].size();
        for (int k = 0; k < (sz); ++k) {
          int o = g[i][k];
          if (can[o][j]) {
            fa[i][j][0] = o;
            break;
          }
        }
      }
    }
  }
  for (int k = 1; k < 13; ++k) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        fa[i][j][k] = fa[fa[i][j][k - 1]][j][k - 1];
      }
    }
  }
  for (int i = 1; i <= q; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    --c;
    if (fa[a][b][12] || !can[a][b]) {
      puts("-1");
      continue;
    }
    for (int i = 12; i >= 0; --i) {
      if (fa[a][b][i] && (1 << i) <= c) {
        c -= (1 << i);
        a = fa[a][b][i];
      }
    }
    if (c)
      puts("-1");
    else
      printf("%d\n", a);
  }
  return 0;
}
