#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "sz = " << vc.size() << endl << "[";
  for (const T& v : vc) o << v << ",";
  o << "]";
  return o;
}
int N, M, Q;
pair<int, int> e[200000];
const int MQ = 200000;
bool ans[200000];
int l[MQ], r[MQ], s[MQ], t[MQ];
int mn[1000][1000];
vector<int> qs[200000];
int inf = 1e8;
int main() {
  cin >> N >> M >> Q;
  for (int i = 0; i < (int)(M); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    e[i] = pair<int, int>(x, y);
  }
  for (int i = 0; i < (int)(Q); i++) {
    scanf("%d%d%d%d", l + i, r + i, s + i, t + i);
    s[i]--, t[i]--;
    l[i]--, r[i]--;
    qs[l[i]].push_back(i);
  }
  for (int i = 0; i < (int)(N); i++)
    for (int j = 0; j < (int)(N); j++) mn[i][j] = inf;
  for (int i = M - 1; i >= 0; i--) {
    int a = e[i].first, b = e[i].second;
    mn[a][b] = mn[b][a] = i;
    for (int v = 0; v < (int)(N); v++)
      mn[a][v] = min(mn[a][v], mn[b][v]), mn[b][v] = min(mn[b][v], mn[a][v]);
    for (int id : qs[i]) ans[id] = (mn[s[id]][t[id]] <= r[id]);
  }
  for (int i = 0; i < (int)(Q); i++) {
    if (ans[i])
      puts("Yes");
    else
      puts("No");
  }
}

### Prompt

Please create a solution in Cpp to the following problem:

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 li, ri, si and ti if it's possible for Gerda to get to the palace on time.

Input

The first line of the input contains integers n, m 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 vi and ui (1 ≤ vi, ui ≤ n, vi ≠ ui) — the indices of the intersections connected by the i-th road. It's possible to get both from vi to ui and from ui to vi 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 li, ri, si and ti (1 ≤ li ≤ ri ≤ m, 1 ≤ si, ti ≤ n, si ≠ ti) — 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 ri) or "No" (without quotes) otherwise.

Example

Input

5 4 6
1 2
2 3
3 4
3 5
1 3 1 4
1 3 2 4
1 4 4 5
1 4 4 1
2 3 1 4
2 2 2 3


Output

Yes
Yes
Yes
No
No
Yes

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "sz = " << vc.size() << endl << "[";
  for (const T& v : vc) o << v << ",";
  o << "]";
  return o;
}
int N, M, Q;
pair<int, int> e[200000];
const int MQ = 200000;
bool ans[200000];
int l[MQ], r[MQ], s[MQ], t[MQ];
int mn[1000][1000];
vector<int> qs[200000];
int inf = 1e8;
int main() {
  cin >> N >> M >> Q;
  for (int i = 0; i < (int)(M); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    e[i] = pair<int, int>(x, y);
  }
  for (int i = 0; i < (int)(Q); i++) {
    scanf("%d%d%d%d", l + i, r + i, s + i, t + i);
    s[i]--, t[i]--;
    l[i]--, r[i]--;
    qs[l[i]].push_back(i);
  }
  for (int i = 0; i < (int)(N); i++)
    for (int j = 0; j < (int)(N); j++) mn[i][j] = inf;
  for (int i = M - 1; i >= 0; i--) {
    int a = e[i].first, b = e[i].second;
    mn[a][b] = mn[b][a] = i;
    for (int v = 0; v < (int)(N); v++)
      mn[a][v] = min(mn[a][v], mn[b][v]), mn[b][v] = min(mn[b][v], mn[a][v]);
    for (int id : qs[i]) ans[id] = (mn[s[id]][t[id]] <= r[id]);
  }
  for (int i = 0; i < (int)(Q); i++) {
    if (ans[i])
      puts("Yes");
    else
      puts("No");
  }
}

```