#include <bits/stdc++.h>
using namespace std;
const int N = 3000 + 2;
const int LOG = 12;
vector<int> adj[N];
bool in_stack[N];
struct tree {
  short par[N][LOG + 1];
  short h[N];
  int root;
  bitset<N> reachable;
  void build(int root) {
    this->root = root;
    memset(par, -1, sizeof par);
    in_stack[root] = true;
    dfs(root, -1, 1);
    in_stack[root] = false;
  }
  int dfs(int v, int p, bool keep) {
    if (keep) reachable[v] = 1;
    par[v][0] = p;
    for (int i = 1; i < LOG; i++)
      if (par[v][i - 1] != -1) par[v][i] = par[par[v][i - 1]][i - 1];
    int mn = h[v] + 1;
    for (auto u : adj[v]) {
      if (in_stack[u]) mn = min(mn, (int)h[u]);
      if (h[u] || u == root) continue;
      h[u] = h[v] + 1;
      in_stack[u] = true;
      mn = min(mn, dfs(u, v, keep && (mn > h[v])));
      in_stack[u] = false;
    }
    return mn;
  }
  int get_dep(int v, int dep) {
    dep--;
    if (!reachable[v] || h[v] < dep) return -1;
    for (int i = LOG; i >= 0; i--)
      if (par[v][i] != -1 && h[par[v][i]] >= dep) v = par[v][i];
    return v;
  }
} t[N];
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    adj[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) sort(adj[i].begin(), adj[i].end());
  for (int i = 1; i <= n; i++) t[i].build(i);
  for (int i = 0; i < q; i++) {
    int s, t, k;
    scanf("%d %d %d", &s, &t, &k);
    int res = ::t[s].get_dep(t, k);
    printf("%d\n", res);
  }
}
