#include <bits/stdc++.h>
using namespace std;
vector<int> teleportit[10000];
int (etaisyydet[2500])[2500];
int n, m, q;
bool paasee(int a, int b, int c)
{
vector<int> next;
vector<int> nextnext;
unordered_set<int> kaydaan;
if (a == b && c == 0) {
return true;
}
for (auto neighbor : teleportit[a]) {
next.push_back(neighbor);
}
while (c > 0) {
c--;
for (auto neighbor : next) {
kaydaan.erase(neighbor);
if (c == 0 && neighbor == b) {
return true;
}
for (auto neighneighbor : teleportit[neighbor]) {
if (!kaydaan.contains(neighneighbor)) {
nextnext.push_back(neighneighbor);
kaydaan.insert(neighneighbor);
}
}
}
next = nextnext;
nextnext = {};
}
return false;
}
int main()
{
cin >> n >> m >> q;
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
teleportit[a].push_back(b);
teleportit[b].push_back(a);
}
for (int i = 0; i < q; i++) {
int a, b, c;
cin >> a >> b >> c;
if (paasee(a, b, c)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}