Problem: In Fire City, there are n intersections and m one-way roads. The i-th road goes from intersection a_i to b_i and has length l_i miles. 

There are q cars that may only drive along those roads. The i-th car starts at intersection v_i and has an odometer that begins at s_i, increments for each mile driven, and resets to 0 whenever it reaches t_i. Phoenix has been tasked to drive cars along some roads (possibly none) and return them to their initial intersection with the odometer showing 0.

For each car, please find if this is possible. 

A car may visit the same road or intersection an arbitrary number of times. The odometers don't stop counting the distance after resetting, so odometers may also be reset an arbitrary number of times.

Input

The first line of the input contains two integers n and m (2 ≤ n ≤ 2 ⋅ 10^5; 1 ≤ m ≤ 2 ⋅ 10^5) — the number of intersections and the number of roads, respectively.

Each of the next m lines contain three integers a_i, b_i, and l_i (1 ≤ a_i, b_i ≤ n; a_i ≠ b_i; 1 ≤ l_i ≤ 10^9) — the information about the i-th road. The graph is not necessarily connected. It is guaranteed that between any two intersections, there is at most one road for each direction.

The next line contains an integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of cars.

Each of the next q lines contains three integers v_i, s_i, and t_i (1 ≤ v_i ≤ n; 0 ≤ s_i < t_i ≤ 10^9) — the initial intersection of the i-th car, the initial number on the i-th odometer, and the number at which the i-th odometer resets, respectively.

Output

Print q answers. If the i-th car's odometer may be reset to 0 by driving through some roads (possibly none) and returning to its starting intersection v_i, print YES. Otherwise, print NO.

Examples

Input


4 4
1 2 1
2 3 1
3 1 2
1 4 3
3
1 1 3
1 2 4
4 0 1


Output


YES
NO
YES


Input


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


Output


YES
YES

Note

The illustration for the first example is below:

<image>

In the first query, Phoenix can drive through the following cities: 1 → 2 → 3 → 1 → 2 → 3 → 1. The odometer will have reset 3 times, but it displays 0 at the end.

In the second query, we can show that there is no way to reset the odometer to 0 and return to intersection 1.

In the third query, the odometer already displays 0, so there is no need to drive through any roads.

Below is the illustration for the second example: 

<image>

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e5+5,maxm=2e5+5;
struct Edge{
    int to,w,nxt;
}e1[maxm],e2[maxm];
int cnt1,cnt2;
int head1[maxn],head2[maxn];
int read(){
    int x=0,y=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')y=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*y;
}
void add1(int u,int v,int w){
    e1[cnt1]=(Edge){v,w,head1[u]};
    head1[u]=cnt1++;
    return ;
}
void add2(int u,int v,int w){
    e2[cnt2]=(Edge){v,w,head2[u]};
    head2[u]=cnt2++;
    return ;
}
int dfsnum,scc;
int b[maxn];
int dfn[maxn],low[maxn];
bool vis[maxn];
stack<int>s;
void tarjan(int x){
    dfn[x]=low[x]=++dfsnum;
    vis[x]=1;s.push(x);
    for(int i=head1[x];i!=-1;i=e1[i].nxt){
        int tmp=e1[i].to;
        if(!dfn[tmp]){tarjan(tmp);low[x]=min(low[x],low[tmp]);}
        else if(vis[tmp])low[x]=min(low[x],dfn[tmp]);
    }
    if(dfn[x]==low[x]){
        scc++;
        while(s.top()^x){b[s.top()]=scc;vis[s.top()]=0;s.pop();}
        b[x]=scc;vis[x]=0;s.pop();
    }
    return ;
}
ll p[maxn],q[maxn];
ll res[maxn];
void dfs1(int x){
    vis[x]=1;
    for(int i=head1[x];i!=-1;i=e1[i].nxt){
        int tmp=e1[i].to;
        if(vis[tmp]||b[tmp]!=b[x])continue;
        p[tmp]=p[x]+e1[i].w;
        dfs1(tmp);
    }
    return ;
}
void dfs2(int x){
    vis[x]=1;
    for(int i=head2[x];i!=-1;i=e2[i].nxt){
        int tmp=e2[i].to;
        if(vis[tmp]||b[tmp]!=b[x])continue;
        q[tmp]=q[x]+e2[i].w;
        dfs2(tmp);
    }
    return ;
}
ll gcd(ll x,ll y){
    return y==0?x:gcd(y,x%y);
}
int main(){
    int n,m,Q;
    n=read();m=read();
    memset(head1,-1,sizeof(head1));
    memset(head2,-1,sizeof(head2));
    for(int i=1;i<=m;i++){
        int u,v,w;
        u=read();v=read();w=read();
        add1(u,v,w);
        add2(v,u,w);
    }
    for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i);
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=n;i++)if(!vis[i])dfs1(i);
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=n;i++)if(!vis[i])dfs2(i);
    for(int i=1;i<=n;i++){
        for(int j=head1[i];j!=-1;j=e1[j].nxt){
            int tmp=e1[j].to;
            if(b[tmp]^b[i])continue;
            res[b[i]]=gcd(res[b[i]],p[i]+e1[j].w+q[tmp]);
        }
    }
    Q=read();
    for(int i=1;i<=Q;i++){
        int x,s,t;
        x=read();s=read();t=read();
        if(s%gcd(res[b[x]],t))puts("NO");
        else puts("YES");
    }
    return 0;
}