#include <bits/stdc++.h>
using namespace std;
int read() {
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  int x = ch - '0';
  while (1) {
    ch = getchar();
    if (ch < '0' || ch > '9') return x;
    x = (x << 3) + (x << 1) + ch - '0';
  }
}
vector<int> G[3005], G2[3005];
bool vis[3005], go[3005][3005];
void build(int x, int n) {
  for (int i = 1; i <= n; i++) G2[i].clear();
  for (int i = 1; i <= n; i++) {
    for (int j : G[i])
      if (go[j][x]) {
        G2[j].emplace_back(i);
        break;
      }
  }
}
void dfs(int x, int u) {
  go[x][u] = 1;
  vis[u] = 1;
  for (int v : G[u])
    if (!vis[v]) dfs(x, v);
}
struct second {
  int id, x, y, k;
  bool operator<(const second& rhs) const { return y < rhs.y; }
} Q[400005];
vector<pair<int, int> > QQ[3005];
int tmp[3005], ans[400005];
void dfs2(int u, int cur) {
  vis[u] = 1;
  tmp[cur] = u;
  for (pair<int, int> p : QQ[u])
    if (p.second <= cur) ans[p.first] = tmp[cur + 1 - p.second];
  for (int v : G2[u])
    if (!vis[v]) dfs2(v, cur + 1);
}
int main() {
  int n = read(), m = read(), q = read();
  while (m--) {
    int x = read(), y = read();
    G[x].emplace_back(y);
  }
  for (int i = 1; i <= n; i++) sort(G[i].begin(), G[i].end());
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) vis[j] = 0;
    dfs(i, i);
  }
  for (int i = 0; i < q; i++) Q[i] = (second){i, read(), read(), read()};
  sort(Q, Q + q);
  for (int i = 0; i < q; i++) ans[i] = -1;
  for (int i = 0; i < q; i++) {
    QQ[Q[i].x].emplace_back(make_pair(Q[i].id, Q[i].k));
    if (i == q - 1 || Q[i].y != Q[i + 1].y) {
      build(Q[i].y, n);
      for (int j = 1; j <= n; j++) vis[j] = 0;
      dfs2(Q[i].y, 1);
      for (int i = 1; i <= n; i++) QQ[i].clear();
    }
  }
  for (int i = 0; i < q; i++) printf("%d\n", ans[i]);
  return 0;
}
