#include <bits/stdc++.h>
using namespace std;
int n, m, q;
short qans[400000], nxt[3000][12], vis[3000], gxt[3000];
vector<short> edges[3000], redges[3000];
vector<pair<short, int>> queries[3000];
void rdfs(short i) {
  if (nxt[i][0] != -1) return;
  nxt[i][0] = 0;
  for (auto r : redges[i]) rdfs(r);
}
void dfs(short i) {
  for (auto e : edges[i])
    if (nxt[e][0] != -1) {
      nxt[i][0] = e;
      break;
    }
}
short gfs(short t, short i) {
  if (gxt[i] != -1)
    return gxt[i];
  else if (nxt[i][0] == t)
    return gxt[i] = 1;
  else if (vis[nxt[i][0]])
    return gxt[i] = 0;
  else {
    vis[i] = true;
    gxt[i] = gfs(t, nxt[i][0]);
    vis[i] = false;
    return gxt[i];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> q;
  short x, y, kk, kh, kl;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    edges[x - 1].push_back(y - 1);
    redges[y - 1].push_back(x - 1);
  }
  for (int i = 0; i < n; i++) sort(edges[i].begin(), edges[i].end());
  for (int i = 0; i < q; i++) {
    cin >> x >> y >> kk, x--, y--, kk--;
    queries[y].push_back(make_pair(x, i));
    qans[i] = kk;
  }
  memset(vis, false, (short)n * sizeof(bool));
  for (int k = 0; k < n; k++) {
    memset(nxt, -1, sizeof(nxt));
    memset(gxt, -1, sizeof(gxt));
    rdfs(k);
    for (int i = 0; i < n; i++)
      if (i != k && nxt[i][0] != -1) dfs(i);
    for (int i = 0; i < n; i++)
      if (i != k && nxt[i][0] != -1) gfs(k, i);
    for (int l = 1; l < 12; l++)
      for (int i = 0; i < n; i++)
        if (i != k && nxt[i][0] != -1 && gxt[i])
          if (nxt[i][l - 1] != -1 && nxt[i][l - 1] != k)
            nxt[i][l] = nxt[nxt[i][l - 1]][l - 1];
    for (auto &qr : queries[k]) {
      if (nxt[qr.first][0] == -1 || !gxt[qr.first])
        qans[qr.second] = -1;
      else {
        kk = qans[qr.second];
        for (kh = qr.first, kl = 0; kh != -1 && kk != 0; kk >>= 1, kl++)
          kh = (kk & 1) ? nxt[kh][kl] : kh;
        if (kh == -1)
          qans[qr.second] = -1;
        else
          qans[qr.second] = kh + 1;
      }
    }
  }
  for (int i = 0; i < q; i++) cout << qans[i] << endl;
  return 0;
}
