#include <bits/stdc++.h>
using namespace std;
const int N = 3005, Q = 400005;
struct node {
  int st, dis, id;
};
int n, m, q, x, y, z, cnt = 0, ans[Q], to[N], nxt[N], head[N], fa[N][15],
                      pre[N];
vector<node> e[N];
void add(int u, int v) {
  to[++cnt] = v;
  nxt[cnt] = head[u];
  head[u] = cnt;
}
void dfs(int u, int fa) {
  for (int i = head[u]; i; i = nxt[i])
    if (to[i] != fa && ((!pre[to[i]]) || (pre[to[i]] > u))) {
      pre[to[i]] = u;
      dfs(to[i], fa);
    }
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    add(y, x);
  }
  for (int i = 1; i <= q; ++i) {
    scanf("%d%d%d", &x, &y, &z);
    e[y].push_back((node){x, z, i});
  }
  for (int i = 1; i <= n; ++i)
    if (e[i].size()) {
      memset(pre, 0, sizeof(pre));
      dfs(i, i);
      for (int j = 1; j <= n; ++j) fa[j][0] = pre[j];
      for (int j = 1; j < 15; ++j)
        for (int k = 1; k <= n; ++k) fa[k][j] = fa[fa[k][j - 1]][j - 1];
      for (int j = 0; j < e[i].size(); ++j) {
        int u = e[i][j].st, w = e[i][j].dis - 1, now = e[i][j].id;
        if ((!pre[u]) || (fa[u][14])) {
          ans[now] = -1;
          continue;
        }
        for (int k = 0; w; w >>= 1, ++k)
          if (w & 1) u = fa[u][k];
        ans[now] = u ? u : -1;
      }
    }
  for (int i = 1; i <= q; ++i) printf("%d\n", ans[i]);
  return 0;
}
