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>

using ll = long long;
const int maxn = 4e5 + 2222;

int n,m,q,low[maxn],dfn[maxn],vis[maxn],idx,in[maxn],cnt,hd[maxn],tl,d[maxn],anc[maxn][20];

struct edge {
	int v,w,nxt;
} E[maxn << 1];

void add_edge(int u,int v,int w) { E[++tl].v = v; E[tl].w = w; E[tl].nxt = hd[u]; hd[u] = tl; }

std::vector<int>ch[maxn];
std::stack<int>stk;
ll g[maxn],dp[maxn];

ll gcd(ll a,ll b) { return b == 0 ? a : gcd(b,a % b); }

void tarjan(int u) {
	stk.push(u);
	low[u] = dfn[u] = ++idx;
	for (int v:ch[u]) {
		if (!dfn[v]) {
			tarjan(v);
			low[u] = std::min(low[u],low[v]);
		} else if (!in[v])
			low[u] = std::min(low[u],dfn[v]);
	} if (low[u] == dfn[u]) {
		++cnt;
		while (1) {
			int x = stk.top(); stk.pop();
			in[x] = cnt;
			if (x == u) break;
		} 
	}
}

int lca(int u,int v) {
	if (!u) return v;
	if (d[u] < d[v]) std::swap(u,v);
	for (int i = 18; i >= 0; i --) if (d[anc[u][i]] >= d[v]) u = anc[u][i];
	if (u == v) return u;
	for (int i = 18; i >= 0; i --) if (anc[u][i] != anc[v][i]) {
		u = anc[u][i]; v = anc[v][i];
	} return anc[u][0];
}		

ll dis(int u,int v) { 
	return std::abs(dp[u] - dp[v]);
}

void dfs(int u,int f) {
	vis[u] = 1;
	anc[u][0] = f;
	d[u] = d[f] + 1;
	for (int i = 1; i <= 18; ++ i) 
		anc[u][i] = anc[anc[u][i-1]][i-1];
	for (int i = hd[u]; i; i = E[i].nxt) {
		int v = E[i].v, w = E[i].w;
		if (in[v] != in[u]) continue;
		if (!vis[v]) {
			dp[v] = dp[u] + w;
			dfs(v,u);
		} else {
			ll len = std::abs(dp[u] + w - dp[v]);
		//	printf(">%lld\n",len);
			if (!g[in[u]]) g[in[u]] = len;
			else g[in[u]] = gcd(g[in[u]],len);
		}
	}
}

int main() {
	scanf("%d%d",&n,&m);
	for (int i = 1; i <= m; ++ i) {
		int a,b,l;
		scanf("%d%d%d",&a,&b,&l);
		add_edge(a,b,l);
		ch[a].push_back(b);
	} for (int i = 1; i <= n; ++ i)
		if (!dfn[i]) tarjan(i);
	for (int i = 1; i <= n; ++ i) 
		if (!vis[i]) dfs(i,0);
	scanf("%d",&q);
	while (q--) {
		ll s,t;
		int u;
		scanf("%d%lld%lld",&u,&s,&t);
		s = t - s;
	//	printf(">%lld\n",g[in[u]]);
		ll d = gcd(t,g[in[u]]);
		if (s % d == 0) puts("YES");
		else puts("NO");
	}
	return 0;
}