#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 5;
const int maxq = 4e5 + 5;
struct Item {
  int u, v, q, id;
  bool operator<(const Item& item) const { return u < item.u; }
} items[maxq];
int dfn[maxn], low[maxn], vis[maxn], vtm;
int path[maxn], ans[maxq];
vector<int> G[maxn];
vector<Item> qary[maxn];
void tarjan(int u, int dep, bool cant) {
  path[dep] = u;
  low[u] = dfn[u] = ++vtm;
  vis[u] = 1;
  int sz = qary[u].size();
  if (!cant)
    for (int(i) = 0; (i) < (sz); (i)++) {
      Item& item = qary[u][i];
      if (item.q <= dep) ans[item.id] = path[item.q];
    }
  sz = G[u].size();
  for (int(i) = 0; (i) < (sz); (i)++) {
    int v = G[u][i];
    if (!vis[v]) {
      tarjan(v, dep + 1, cant | (low[u] < dfn[u]));
      low[u] = min(low[u], low[v]);
      cant |= low[v] < dfn[v];
    } else if (vis[v] == 1)
      low[u] = min(low[u], dfn[v]);
  }
  vis[u] = 2;
}
int main() {
  int n, m, q, u, v;
  scanf("%d %d %d", &n, &m, &q);
  for (int(i) = 0; (i) < (m); (i)++) {
    scanf("%d %d", &u, &v);
    G[u].push_back(v);
  }
  for (int(i) = (1); (i) <= (n); (i)++) sort(G[i].begin(), G[i].end());
  for (int(i) = 0; (i) < (q); (i)++) {
    Item& item = items[i];
    scanf("%d %d %d", &item.u, &item.v, &item.q);
    item.q--;
    item.id = i;
  }
  sort(items, items + q);
  memset((ans), (-1), sizeof(ans));
  for (int(i) = 0; (i) < (q); (i)++) {
    Item& item = items[i];
    qary[item.v].push_back(item);
    if (i == q - 1 || item.u != items[i + 1].u) {
      vtm = 0, memset((vis), (0), sizeof(vis));
      tarjan(item.u, 0, false);
      for (int(j) = (1); (j) <= (n); (j)++) qary[j].clear();
    }
  }
  for (int(i) = 0; (i) < (q); (i)++) printf("%d\n", ans[i]);
  return 0;
}
