#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3011;
const int MAXQ = 400100;
const int INF = 0x3f3f3f3f;
struct edge {
  int v;
  edge *next;
} pool[10 * MAXN], *h[MAXN];
vector<int> task[MAXN][MAXN];
int val[MAXQ];
int n, m, q, a[MAXN][MAXN], top = -1;
int vis[MAXN], cur[MAXN], ans[MAXQ], Index;
inline void addedge(int u, int v) {
  edge *tmp = &pool[++top];
  tmp->v = v;
  tmp->next = h[u];
  h[u] = tmp;
}
inline void addtask(int u, int v, int len, int id) {
  task[u][v].push_back(id);
  val[id] = len;
}
inline void push(int x) { cur[++Index] = x; }
inline void pop() { cur[Index--] = 0; }
int dfs_2(int u) {
  int min_h = vis[u] + 1;
  for (edge *tmp = h[u]; tmp != NULL; tmp = tmp->next) {
    int v = tmp->v;
    if (vis[v] == 0) {
      vis[v] = vis[u] + 1;
      min_h = min(min_h, dfs_2(v));
    } else if (vis[v] > 0)
      min_h = min(min_h, vis[v]);
  }
  vis[u] = -vis[u];
  return min_h;
}
int dfs(int u, int root) {
  push(u);
  int l = task[root][u].size();
  for (int i = 0; i < l; i++) {
    int id = task[root][u][i];
    int w = val[id];
    if (w <= Index) ans[id] = cur[w];
  }
  bool type = true;
  int min_h = vis[u] + 1;
  for (edge *tmp = h[u]; tmp != NULL; tmp = tmp->next) {
    int v = tmp->v;
    if (vis[v] == 0) {
      vis[v] = vis[u] + 1;
      if (type == true) {
        min_h = min(min_h, dfs(v, root));
        if (min_h <= vis[u]) type = false;
      } else {
        min_h = min(min_h, dfs_2(v));
      }
    } else if (vis[v] > 0) {
      min_h = min(min_h, vis[v]);
      if (min_h <= vis[u]) type = false;
    }
  }
  vis[u] = -vis[u];
  pop();
  return min_h;
}
void init() {
  int x1, x2, x3;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x1, &x2);
    a[x1][x2] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = n; j >= 1; j--) {
      if (a[i][j]) addedge(i, j);
    }
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d", &x1, &x2, &x3);
    addtask(x1, x2, x3, i);
    ans[i] = -1;
  }
  for (int i = 1; i <= n; i++) {
    Index = 0;
    for (int j = 1; j <= n; j++) vis[j] = 0;
    vis[i] = 1;
    dfs(i, i);
  }
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
}
int main(int argc, char **argv) {
  init();
  return 0;
}
