#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#define MP make_pair
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, kyselyja, x, a, b;
cin >> n >> m >> kyselyja;
vector<int> v[n];
for (int i = 0; i < m; i++)
{
cin >> a >> b;
a--;
b--;
v[a].push_back(b);
v[b].push_back(a);
}
bool parillinen[n];
bool pariton[n];
for (int i = 0; i < kyselyja; i++)
{
cin >> a >> b >> x;
a--;
b--;
if (x == 0)
{
if (a == b)
{
cout << "YES\n";
}
else
{
cout << "NO\n";
}
continue;
}
if (a== b && (x&2==0){
cout << "YES\n";
continue;
}
queue<pair<int, int>> q;
fill(parillinen, parillinen + n, 0);
fill(pariton, pariton + n, 0);
parillinen[a] = 1;
for (int t : v[a])
{
q.push(MP(t, 1));
// pariton[t] = 1;
}
while (true)
{
if (q.empty())
{
cout << "NO\n";
break;
}
auto p = q.front();
q.pop();
int index = p.first;
int d = p.second;
if (d > x)
{
cout << "NO\n";
break;
}
if ((d & 1))
{
if (pariton[index])
{
continue;
}
pariton[index] = 1;
}
else
{
if (parillinen[index])
{
continue;
}
parillinen[index] = 1;
}
if (index == b && (x & 1) == (d & 1))
{
cout << "YES\n";
break;
}
for (int t : v[index])
{
q.push(MP(t, d + 1));
}
}
}
}