#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000, maxq = 4e5, maxlog = 12;
struct Query {
  int s, t, k, i;
  bool operator<(const Query &b) const { return t < b.t; }
} qs[maxq];
int ans[maxq];
int n, m, q;
vector<int> g[maxn];
vector<int> gt[maxn];
bool vis[maxn];
void Fill(int u) {
  vis[u] = true;
  for (int v : gt[u]) {
    if (!vis[v]) {
      Fill(v);
    }
  }
}
namespace solver {
int t;
vector<int> g[maxn];
int par[maxn][maxlog];
int dep[maxn];
void InitLCA(int u) {
  for (int j = 1; 1 << j <= dep[u]; ++j) {
    par[u][j] = par[par[u][j - 1]][j - 1];
  }
  for (int v : g[u]) {
    if (v == par[u][0]) continue;
    dep[v] = dep[u] + 1;
    par[v][0] = u;
    InitLCA(v);
  }
}
void Init(int _t) {
  t = _t;
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  memset(vis, 0, sizeof vis);
  Fill(t);
  for (int u = 0; u < n; ++u) {
    if (u == t) continue;
    int out = -1;
    for (int v : ::g[u]) {
      if (vis[v]) {
        out = v;
        break;
      }
    }
    if (out >= 0) {
      g[u].push_back(out);
      g[out].push_back(u);
    }
  }
  memset(par, -1, sizeof par);
  memset(dep, -1, sizeof dep);
  dep[t] = 0;
  InitLCA(t);
}
int KthPar(int u, int k) {
  for (int i = 0; k; ++i) {
    if (k >> i & 1) {
      u = par[u][i];
      k -= 1 << i;
    }
  }
  return u;
}
int Get(int s, int k) {
  if (dep[s] == -1) return -1;
  --k;
  if (dep[s] < k) return -1;
  return KthPar(s, k);
}
}  // namespace solver
int main(void) {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    g[u].push_back(v);
    gt[v].push_back(u);
  }
  for (int i = 0; i < n; ++i) {
    sort(g[i].begin(), g[i].end());
  }
  for (int i = 0; i < q; ++i) {
    scanf("%d%d%d", &qs[i].s, &qs[i].t, &qs[i].k);
    --qs[i].s;
    --qs[i].t;
    qs[i].i = i;
  }
  sort(qs, qs + q);
  for (int i = 0; i < q; ++i) {
    if (i == 0 || qs[i].t != qs[i - 1].t) {
      solver::Init(qs[i].t);
    }
    ans[qs[i].i] = solver::Get(qs[i].s, qs[i].k);
  }
  for (int i = 0; i < q; ++i) {
    printf("%d\n", ans[i] == -1 ? -1 : ans[i] + 1);
  }
  return 0;
}
