#include<bits/stdc++.h>
using namespace std;
const int N=4*1e5+5;
struct tree{
int l,r;
}tr[N*4];
struct asd{
int x,y;
}b[N];
int n,m,k;
vector<int> s[N*4];
int fa[N];
void build(int p,int l,int r){
tr[p].l=l,tr[p].r=r;
if(l==r) return;
int mid=(l+r)/2;
build(p*2,l,mid);
build(p*2+1,mid+1,r);
}
void change(int p,int l,int r,int v){
if(l>r) return;
if(tr[p].l>=l && tr[p].r<=r){
s[p].push_back(v);
return;
}
int mid=(tr[p].l+tr[p].r)/2;
if(l<=mid) change(p*2,l,r,v);
if(r>mid) change(p*2+1,l,r,v);
}
int sum[N];
bool flat[N];
struct qwe{
int a,b,c,d;
}st[N];
int top=0;
int get_fa(int x){
while(fa[x]!=x) x=fa[x];
return fa[x];
}
int merge(int x,int y){
int fx=get_fa(x),fy=get_fa(y);
st[++top]={fx,fy,sum[fx],sum[fy]};
if(sum[fx]>sum[fy]) swap(fx,fy);
fa[fx]=fy;
sum[fy]+=sum[fx];
}
void dfs(int p){
int now=top;
int tmp=0;
for(int i=0;i<s[p].size();i++){
int id=s[p][i];
int x=b[id].x,y=b[id].y;
int fx=get_fa(x),fy=get_fa(y);
if(fx==fy){
for(int j=tr[p].l;j<=tr[p].r;j++){
printf("No\n");
}
tmp=1;
break;
}
merge(x+n,y);
merge(x,y+n);
}
if(!tmp){
if(tr[p].l==tr[p].r){
printf("Yes\n");
}
else{
dfs(p*2),dfs(p*2+1);
}
}
while(top>now){
int fx=st[top].a,fy=st[top].b,c=st[top].c,d=st[top].d;
fa[fx]=fx;
fa[fy]=fy;
sum[fx]=c;
sum[fy]=d;
top--;
}
}
int main(){
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=2*n;i++){
sum[i]=1;
fa[i]=i;
}
build(1,1,k);
for(int i=1;i<=m;i++){
int x,y,l,r;
scanf("%d%d%d%d",&x,&y,&l,&r);
b[i].x=x,b[i].y=y;
change(1,l+1,r,i);
}
dfs(1);
}