#include <bits/stdc++.h>
using namespace std;
void readi(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readll(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
void writes(string s) { puts(s.c_str()); }
void writeln() { writes(""); }
void writei(int x) {
  if (x < 0) {
    printf("-");
    x = -x;
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
void writell(long long x) {
  if (x < 0) {
    printf("-");
    x = -x;
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
int n, m, q, i, x, y, z, fa[3333][13], ans[444444];
vector<pair<pair<int, int>, int> > query[3333];
vector<int> e[3333];
void dfs(int x, int par) {
  int i;
  for (i = 0; i < e[x].size(); i++) {
    if (e[x][i] == par) continue;
    if ((!fa[e[x][i]][0]) || fa[e[x][i]][0] > x)
      fa[e[x][i]][0] = x, dfs(e[x][i], par);
  }
}
int main() {
  readi(n);
  readi(m);
  readi(q);
  for (i = 1; i <= m; i++) {
    readi(x);
    readi(y);
    e[y].push_back(x);
  }
  for (i = 1; i <= q; i++) {
    readi(x);
    readi(y);
    readi(z);
    query[y].push_back(make_pair(make_pair(x, z), i));
  }
  memset(ans, -1, sizeof(ans));
  for (i = 1; i <= n; i++) {
    if (query[i].empty()) continue;
    memset(fa, 0, sizeof(fa));
    dfs(i, i);
    int j, k;
    for (j = 1; j <= 12; j++) {
      for (k = 1; k <= n; k++) {
        fa[k][j] = fa[fa[k][j - 1]][j - 1];
      }
    }
    for (j = 0; j < query[i].size(); j++) {
      x = query[i][j].first.first;
      y = query[i][j].first.second;
      z = query[i][j].second;
      if (fa[x][12] || (!fa[x][0])) continue;
      y--;
      for (k = 0; k <= 12; k++) {
        if (y & (1 << k)) x = fa[x][k];
      }
      if (!x) continue;
      ans[z] = x;
    }
  }
  for (i = 1; i <= q; i++) {
    writei(ans[i]);
    writeln();
  }
  return 0;
}
