#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 3;
vector<int> g[maxn];
vector<vector<int> > query[maxn];
int fa[maxn][13];
int ans[400005];
void dfs(int u, int anc) {
  for (int v : g[u])
    if (v != anc && (!fa[v][0] || fa[v][0] > u)) {
      fa[v][0] = u;
      dfs(v, anc);
    }
}
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  while (m--) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= q; i++) {
    int st, en, k;
    scanf("%d %d %d", &st, &en, &k);
    query[en].emplace_back(vector<int>{st, k, i});
  }
  for (int i = 1; i <= n; i++)
    if (query[i].size()) {
      memset(fa, 0, sizeof(fa));
      dfs(i, i);
      for (int j = 1; j <= 12; j++)
        for (int k = 1; k <= n; k++) fa[k][j] = fa[fa[k][j - 1]][j - 1];
      for (auto &v : query[i]) {
        if (!fa[v[0]][0] || fa[v[0]][12])
          ans[v[2]] = -1;
        else {
          int k = v[1] - 1, u = v[0];
          for (int j = 0; (1 << j) <= k; j++)
            if (k >> j & 1) u = fa[u][j];
          if (u == 0) u = -1;
          ans[v[2]] = u;
        }
      }
    }
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}
