#include <bits/stdc++.h>
using namespace std;
const int N = 3005, M = 100005, mod = 1e9 + 7;
template <class T>
inline void gmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <class T>
inline void gmax(T &x, const T &y) {
  if (x < y) x = y;
}
inline void ch(int &x, int y) { x = (x + y) % mod; }
const int BufferSize = 1 << 25;
char buffer[BufferSize], *Bufferhead, *Buffertail;
int Terminal;
inline char Getchar() {
  if (Bufferhead == Buffertail) {
    int l = fread(buffer, 1, BufferSize, stdin);
    if (!l) {
      Terminal = 1;
      return 0;
    }
    Buffertail = (Bufferhead = buffer) + l;
  }
  return *Bufferhead++;
}
template <class T>
inline bool read(T &x) {
  x = 0;
  char c = Getchar(), rev = 0;
  while (c < '0' || c > '9') {
    c = Getchar();
    rev |= c == '-';
    if (Terminal) return 0;
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = Getchar();
  x = rev ? -x : x;
  return 1;
}
template <class T>
inline void print(T x, const char c) {
  if (!x) {
    putchar('0');
    putchar(c);
    return;
  }
  if (x < 0) putchar('-'), x = -x;
  int m = 0, a[20];
  while (x) a[m++] = x % 10, x /= 10;
  while (m--) putchar(a[m] + '0');
  putchar(c);
}
inline int exp(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = (long long)ans * x % mod;
    x = (long long)x * x % mod;
    y >>= 1;
  }
  return ans;
}
struct node {
  int x, y, k, num;
} query[400005];
int n, m, Q, a[N], ans[400005];
vector<int> g[N];
vector<pair<int, int> > ask[N];
bool vis[N], v[N], bad[N];
void make(int x) {
  if (bad[x]) return;
  bad[x] = 1;
  for (int y : g[x]) make(y);
}
void dfs(int x, int d = 1) {
  if (bad[x]) return;
  if (v[x]) {
    make(x);
    return;
  }
  if (vis[x]) return;
  vis[x] = v[x] = 1;
  a[d] = x;
  for (auto i : ask[x])
    if (d >= i.first) ans[i.second] = a[i.first];
  for (int y : g[x]) dfs(y, d + 1);
  v[x] = 0;
}
inline bool cmp(node a, node b) { return a.x < b.x; }
int main() {
  scanf("%d%d%d", &n, &m, &Q);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
  }
  for (int i = 1; i <= Q; i++) {
    int x, y, k;
    scanf("%d%d%d", &x, &y, &k);
    query[i] = (node){x, y, k, i};
  }
  memset(ans, -1, sizeof(ans));
  sort(query + 1, query + Q + 1, cmp);
  for (int i = 1; i <= n; i++) sort(g[i].begin(), g[i].end());
  for (int i = 1, j = 1; i <= n; i++) {
    memset(vis, 0, sizeof(vis));
    memset(v, 0, sizeof(v));
    memset(bad, 0, sizeof(bad));
    for (int k = 1; k <= n; k++) ask[k].clear();
    while (j <= Q && query[j].x == i) {
      ask[query[j].y].push_back(make_pair(query[j].k, query[j].num));
      j++;
    }
    dfs(i);
  }
  for (int i = 1; i <= Q; i++) print(ans[i], '\n');
  return 0;
}
