#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
#define int ll
// #define N
using namespace std;
int S,Q;
map<tuple<int,int,int,int>,bool>Mp;
inline int dfs(int x,int y,int a,int b)
{
if (x<=0) return 0;
if (a<=0) return 1;
if (x<=1ll*b*S&&a<=1ll*y*S)
{
ll t=min(-x+1ll*b*S,-a+1ll*y*S)/S+1;
b-=t,y-=t;
}
if (b==0) return dfs(a-x+1ll*b*S,b,x,y)^1;
if (x<=1ll*b*S && a-1ll*y*S>=S) return 0;
if (x<=1ll*b*S&&y==0)
{
ll t=(-x+1ll*b*S)/(S-1ll*(a-1ll*y*S))+1;
if (1ll*(a-1ll*y*S)*t>=x) return 0;
x+=t*(-1ll*(a-1ll*y*S));
b-=t;
}
if (a-1ll*y*S>=S) return dfs(a,-x+1ll*b*S,b,x,y)^1;
if (x<=1ll*b*S) return dfs(a,b-1,x,y)^1;
if (x-1ll*b*S>=S&&a<=1ll*y*S) return 1;
if (Mp.count({x,y,a,b})) return Mp[{x,y,a,b}];
bool &res=Mp[{x,y,a,b}];
res=0;
if (x>1ll*b*S)
{
res=dfs(a-x+1ll*b*S,b,x,y)^1;
if (res)return res;
}
if (b>0)
{
res=dfs(a,b-1,x,y)^1;
if (res)return res;
}
return 0;
}
mt19937_64 rnd(time(0));
const int B=300;
void BellaKira()
{
cin>>S>>Q;
while (Q--)
{
int x,y,a,b;
x=rnd()%B+1,y=rnd()%B+1,a=rnd()%B+1,b=rnd()%B+1;
cin>>x>>y>>a>>b;
if (dfs(x,y,a,b)) cout<<"YES\n";
else cout<<"NO\n";
}
}
signed main()
{
IOS;
cin.tie(0);
int T=1;
while (T--)
{
BellaKira();
}
}
/*list:
1.mod 998244353 or 1e9+7 or ???
2.N
3.duipai shuju xingtai duoyidian
...
*/