#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
const int maxm = 200000 + 10;
struct Edge {
  int u, v;
  Edge() {}
  Edge(int u, int v) : u(u), v(v) {}
} e[maxm];
struct Query {
  int l, r, s, t, id;
  bool operator<(const Query& tmp) const { return l < tmp.l; }
} query[maxm];
int n, m, q, cur;
int dp[maxn][maxn];
bool ans[maxm];
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
int main() {
  if (fopen("E.in", "r") != NULL) {
    freopen("E.in", "r", stdin);
    freopen("E.out", "w", stdout);
  }
  n = read(), m = read() + 1, cur = q = read();
  for (int i = 1; i < m; i++) e[i].u = read(), e[i].v = read();
  for (int i = 1; i <= q; i++) {
    query[i].l = read(), query[i].r = read();
    query[i].s = read(), query[i].t = read();
    query[i].id = i;
  }
  sort(query + 1, query + q + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) dp[i][j] = m;
  while (--m) {
    int u = e[m].u, v = e[m].v;
    dp[u][v] = dp[v][u] = m;
    for (int i = 1; i <= n; i++)
      if (dp[u][i] < dp[v][i])
        dp[v][i] = dp[u][i];
      else
        dp[u][i] = dp[v][i];
    while (cur && query[cur].l == m) {
      ans[query[cur].id] = dp[query[cur].s][query[cur].t] <= query[cur].r;
      cur--;
    }
  }
  for (int i = 1; i <= q; i++) puts(ans[i] ? "Yes" : "No");
  return 0;
}
