# Travelling Through the Snow Queen’s Kingdom

Gerda is travelling to the palace of the Snow Queen.

The road network consists of n intersections and m bidirectional roads. Roads are numbered from 1 to m. Snow Queen put a powerful spell on the roads to change the weather conditions there. Now, if Gerda steps on the road i at the moment of time less or equal to i, she will leave the road exactly at the moment i. In case she steps on the road i at the moment of time greater than i, she stays there forever.

Gerda starts at the moment of time l at the intersection number s and goes to the palace of the Snow Queen, located at the intersection number t. Moreover, she has to be there at the moment r (or earlier), before the arrival of the Queen.

Given the description of the road network, determine for q queries l ir is i and t i if it’s possible for Gerda to get to the palace on time.

Input

The first line of the input contains integers nm and q (2 ≤ n ≤ 1000, 1 ≤ m, q ≤ 200 000) — the number of intersections in the road network of Snow Queen’s Kingdom, the number of roads and the number of queries you have to answer.

The i-th of the following m lines contains the description of the road number i. The description consists of two integers v i and u i (1 ≤ v i, u i ≤ nv i ≠ u i) — the indices of the intersections connected by the i-th road. It’s possible to get both from v i to u i and from u i to v i using only this road. Each pair of intersection may appear several times, meaning there are several roads connecting this pair.

Last q lines contain the queries descriptions. Each of them consists of four integers l ir is i and t i (1 ≤ l i ≤ r i ≤ m, 1 ≤ s i, t i ≤ ns i ≠ t i) — the moment of time Gerda starts her journey, the last moment of time she is allowed to arrive to the palace, the index of the starting intersection and the index of the intersection where palace is located.

Output

For each query print “Yes” (without quotes) if Gerda can be at the Snow Queen palace on time (not later than r i) or “No” (without quotes) otherwise.

Example

input

5 4 61 22 33 43 51 3 1 41 3 2 41 4 4 51 4 4 12 3 1 42 2 2 3

output

YesYesYesNoNoYes

Solution:

#include <bits/stdc++.h>

using namespace std;

const int N = 1010;
const int M = 200010;

typedef bitset<N> bs;

bs a[N];
bs mem[M];
int u[M], v[M];
int l[M], r[M], s[M], t[M];
bool ans[M], solved[M];
vector <int> qs[M], qf[M];

void solve(int from, int to) {
int mid = (from + to) >> 1;
for (int j = mid; j >= from; j--) {
a[u[j]] |= a[v[j]];
a[v[j]] = a[u[j]];
for (int q : qs[j]) {
if (!solved[q] && (mid <= r[q] && r[q] <= to)) {
mem[q] = a[s[q]];
}
}
}
for (int j = mid; j >= from; j--) {
a[u[j]].reset();
a[u[j]].set(u[j]);
a[v[j]].reset();
a[v[j]].set(v[j]);
}
for (int j = mid; j <= to; j++) {
for (int q : qf[j]) {
if (!solved[q] && (from <= l[q] && l[q] <= mid)) {
ans[q] = ((mem[q] & a[t[q]]).count() > 0);
solved[q] = true;
}
}
if (j < to) {
a[u[j + 1]] |= a[v[j + 1]];
a[v[j + 1]] = a[u[j + 1]];
}
}
for (int j = mid + 1; j <= to; j++) {
a[u[j]].reset();
a[u[j]].set(u[j]);
a[v[j]].reset();
a[v[j]].set(v[j]);
}
if (from < to) {
solve(from, mid);
solve(mid + 1, to);
}
}

int main() {
int n, m, q;
scanf("%d %d %d", &n, &m, &q);
for (int i = 0; i < m; i++) {
scanf("%d %d", u + i, v + i);
u[i]--; v[i]--;
}
for (int i = 0; i < q; i++) {
scanf("%d %d %d %d", l + i, r + i, s + i, t + i);
l[i]--; r[i]--; s[i]--; t[i]--;
qs[l[i]].push_back(i);
qf[r[i]].push_back(i);
ans[i] = false;
solved[i] = false;
}
for (int i = 0; i < n; i++) {
a[i].set(i);
}
solve(0, m - 1);
for (int i = 0; i < q; i++) {
puts(ans[i] ? "Yes" : "No");
}
return 0;
}