#include #include using namespace std; const int MAXN = 10005; vector graph[MAXN]; bool visited[MAXN]; int dis_odd[MAXN], dis_even[MAXN]; void find_shortest_path() { memset(dis_even, 0x3f, sizeof dis_even); memset(dis_odd, 0x3f, sizeof dis_odd); queue> q; for (int &i: graph[1]) { dis_odd[i] = 1; q.emplace(i, 1); } while (!q.empty()) { int x = q.front().first, y = q.front().second; for (int &i: graph[x]) { if (y % 2 == 0) { if (y + 1 < dis_odd[i]) { dis_odd[i] = y + 1; q.emplace(i, y + 1); } } else { if (y + 1 < dis_even[i]) { dis_even[i] = y + 1; q.emplace(i, y + 1); } } } q.pop(); } } int main() { int n, m, q; cin >> n >> m >> q; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; graph[u].push_back(v); graph[v].push_back(u); } find_shortest_path(); while (q--) { int u, v; cin >> u >> v; if (v % 2 == 0) { if (dis_even[u] > v) cout << "No" << endl; else cout << "Yes" << endl; } else { if (dis_odd[u] > v) cout << "No" << endl; else cout << "Yes" << endl; } } }