#include <bits/stdc++.h>
int n, m, q;
struct edge {
  int to;
  edge* next;
} E[9010], *fir[3010], *rev[3010], *dwn[3010];
struct query {
  int k, ans;
  query* next;
} Q[400010], *ptr[3010][3010], **cur;
bool vis[3010], tag[3010];
int nxt[3010];
void dfs1(int i) {
  vis[i] = 1;
  for (edge* e = rev[i]; e; e = e->next)
    if (!vis[e->to]) dfs1(e->to);
}
int stk[3010];
void dfs2(int i, int d) {
  tag[i] = 1;
  stk[d] = i;
  for (query* it = cur[i]; it; it = it->next)
    it->ans = it->k > d ? -1 : stk[d - it->k];
  for (edge* e = dwn[i]; e; e = e->next) dfs2(e->to, d + 1);
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0, u, v; i < m; i++) {
    scanf("%d%d", &u, &v);
    E[i] = (edge){v, fir[u]}, fir[u] = E + i;
    E[i + m] = (edge){u, rev[v]}, rev[v] = E + i + m;
  }
  for (int i = 0, s, t; i < q; i++) {
    scanf("%d%d%d", &s, &t, &Q[i].k);
    --Q[i].k;
    Q[i].next = ptr[t][s];
    ptr[t][s] = Q + i;
  }
  for (int i = 1; i <= n; i++) {
    memset(vis, 0, sizeof(*vis) * (n + 1));
    memset(nxt, 0, sizeof(*nxt) * (n + 1));
    memset(tag, 0, sizeof(*tag) * (n + 1));
    memset(dwn, 0, sizeof(*dwn) * (n + 1));
    dfs1(i);
    cur = ptr[i];
    for (int j = 1; j <= n; j++)
      if (vis[j] && j != i)
        for (edge* e = fir[j]; e; e = e->next)
          if (vis[e->to])
            if (!nxt[j] || e->to < nxt[j]) nxt[j] = e->to;
    for (int j = 1; j <= n; j++)
      if (vis[j] && nxt[j])
        E[j + m * 2] = (edge){j, dwn[nxt[j]]}, dwn[nxt[j]] = E + j + m * 2;
    dfs2(i, 0);
    for (int j = 1; j <= n; j++)
      if (!tag[j])
        for (query* it = cur[j]; it; it = it->next) it->ans = -1;
  }
  for (int i = 0; i < q; i++) printf("%d\n", Q[i].ans);
}
