#include <bits/stdc++.h>
using namespace std;
vector<int> adj[3010], child[3010];
bool reach[3010][3010], visited[3010];
void build_tree(int u, int flag = 1) {
  visited[u] = true;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (!visited[v]) {
      build_tree(v, flag);
      if (flag) child[u].push_back(v);
    }
    if (reach[v][u]) flag = 0;
  }
}
int s[400010], t[400010], k[400010], ans[400010];
vector<int> query[3010][3010];
int root;
vector<int> path;
void dfs(int u) {
  path.push_back(u);
  for (int i = 0; i < query[root][u].size(); i++) {
    int j = query[root][u][i];
    if (k[j] <= path.size()) {
      ans[j] = path[k[j] - 1];
    }
  }
  for (int i = 0; i < child[u].size(); i++) {
    dfs(child[u][i]);
  }
  path.pop_back();
}
int main() {
  int n, m, q;
  while (scanf("%d%d%d", &n, &m, &q) > 0) {
    while (m--) {
      int x, y;
      scanf("%d%d", &x, &y);
      adj[x].push_back(y);
    }
    memset(reach, false, sizeof reach);
    for (int x = 1; x <= n; x++) {
      reach[x][x] = true;
      queue<int> q;
      q.push(x);
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int i = 0; i < adj[u].size(); i++) {
          int v = adj[u][i];
          if (!reach[x][v]) {
            reach[x][v] = true;
            q.push(v);
          }
        }
      }
      sort(adj[x].begin(), adj[x].end());
    }
    for (int i = 0; i < q; i++) {
      scanf("%d%d%d", &s[i], &t[i], &k[i]);
      query[s[i]][t[i]].push_back(i);
      ans[i] = -1;
    }
    for (root = 1; root <= n; root++) {
      for (int i = 1; i <= n; i++) {
        visited[i] = false;
        child[i].clear();
      }
      build_tree(root);
      path.clear();
      dfs(root);
    }
    for (int i = 0; i < q; i++) {
      printf("%d\n", ans[i]);
    }
    for (int i = 1; i <= n; i++) {
      adj[i].clear();
      child[i].clear();
      for (int j = 1; j <= n; j++) {
        query[i][j].clear();
      }
    }
  }
}
