#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5, M = 4e5 + 5;
struct kkk {
  int id, k;
};
struct sss {
  int s[N], len;
  inline void push(int x) { s[++len] = x; }
  inline int size() { return len; }
  inline void pop() { --len; }
  int operator[](int x) { return s[x]; }
} stk;
vector<kkk> v[N][N];
vector<int> e[N];
bool book[N], vis[N];
int ans[M], cf[N];
int T, n, m, res;
inline void read(int &x) {
  char c;
  for (c = getchar(); c<'0' | c> '9'; c = getchar())
    ;
  for (x = 0; '0' <= c & c <= '9'; c = getchar()) x = x * 10 + c - '0';
}
inline void ins(int x, int y) { e[x].push_back(y); }
inline void dfs(int rot, int x) {
  book[x] = vis[x] = true;
  stk.push(x);
  for (int i = 0, len = v[rot][x].size(), k; i < len; ++i)
    if ((k = v[rot][x][i].k) <= stk.size() && !res)
      ans[v[rot][x][i].id] = stk[k];
  for (int i = 0, len = e[x].size(), y; i < len; ++i)
    if (!vis[y = e[x][i]])
      dfs(rot, y);
    else if (book[y]) {
      ++res;
      ++cf[y];
    }
  res -= cf[x];
  cf[x] = 0;
  stk.pop();
  book[x] = false;
}
int main() {
  int x, y, z;
  read(n);
  read(m);
  read(T);
  for (int i = 1; i <= m; ++i) {
    read(x);
    read(y);
    ins(x, y);
  }
  for (int i = 1; i <= n; ++i) sort(e[i].begin(), e[i].end());
  for (int i = 1; i <= T; ++i) {
    read(x);
    read(y);
    read(z);
    v[x][y].push_back((kkk){i, z});
  }
  memset(ans, -1, T + 1 << 2);
  for (int i = 1; i <= n; ++i) {
    memset(vis, false, n + 1);
    memset(book, false, n + 1);
    res = 0;
    dfs(i, i);
  }
  for (int i = 1; i <= T; ++i) printf("%d\n", ans[i]);
  return 0;
}
