#include <bits/stdc++.h>
using namespace std;
const int maxN = 3003;
const int maxK = 400004;
int n, m, k, vis[maxN], low[maxN], status[maxN], cnt;
vector<int> adj[maxN], dfsStack;
bool reach[maxN];
int query[maxN][maxN], k_th[maxK], ans[maxK];
vector<int> Q, link;
void dfs(int sta, int u) {
  vis[u] = ++cnt;
  low[u] = vis[u] + 1;
  status[u] = 1;
  dfsStack.push_back(u);
  if (reach[u] && query[sta][u]) {
    for (int ind = query[sta][u]; ind != -1; ind = link[ind]) {
      if (k_th[Q[ind]] <= dfsStack.size())
        ans[Q[ind]] = dfsStack[k_th[Q[ind]] - 1];
    }
  }
  for (int v : adj[u]) {
    if (status[v]) {
      if (status[v] == 1) low[u] = min(low[u], vis[v]);
      continue;
    }
    if (low[u] <= vis[u] || !reach[u]) reach[v] = false;
    dfs(sta, v);
    low[u] = min(low[u], low[v]);
  }
  status[u] = 2;
  dfsStack.pop_back();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> k;
  int u, v;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
  }
  for (int u = 1, _b = n; u <= _b; ++u) sort(adj[u].begin(), adj[u].end());
  int s, t;
  Q.push_back(0), link.push_back(0);
  for (int i = 0; i < k; ++i) {
    cin >> s >> t >> k_th[i];
    if (!query[s][t]) {
      query[s][t] = (int)Q.size();
      Q.push_back(i);
      link.push_back(-1);
    } else {
      link.push_back(query[s][t]);
      query[s][t] = (int)Q.size();
      Q.push_back(i);
    }
    ans[i] = -1;
  }
  for (int u = 1, _b = n; u <= _b; ++u) {
    cnt = 0;
    for (int v = 1, _b = n; v <= _b; ++v) status[v] = 0, reach[v] = true;
    dfsStack.clear();
    dfs(u, u);
  }
  for (int i = 0; i < k; ++i) cout << ans[i] << endl;
}
