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 <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <functional>

struct DisjointSetUnion {
	std::vector<int> parent, sizes;
	
	DisjointSetUnion(int size) : parent(size + 1), sizes(size + 1) {
		for (int i = 0; i <= size; i++) {
			parent[i] = i;
			sizes[i] = 1;
		}
	}
	
	int findParent(int x) {
		if (x != parent[x]) {
			parent[x] = findParent(parent[x]);
		}
		return parent[x];
	}
	
	void merge(int a, int b) {
		int pa = findParent(a);
		int pb = findParent(b);
		if (pa == pb) return;
		if (sizes[pa] < sizes[pb]) std::swap(pa, pb);
		parent[pb] = parent[pa];
		sizes[pa] += sizes[pb];
	}
	
	int getSize(int x) {
		return sizes[findParent(x)];
	}
};

namespace SCC {
	using vi = std::vector<int>;
	vi val, comp, z, cont;
	int Time, ncomps;
	template<class G, class F> int dfs(int j, G& g, F& f) {
		int low = val[j] = ++Time, x; z.push_back(j);
		for (auto e : g[j]) if (comp[e] < 0)
			low = std::min(low, val[e] ?: dfs(e,g,f));

		if (low == val[j]) {
			do {
				x = z.back(); z.pop_back();
				comp[x] = ncomps;
				cont.push_back(x);
			} while (x != j);
			f(cont); cont.clear();
			ncomps++;
		}
		return val[j] = low;
	}
	template<class G, class F> void scc(int n, G& g, F f) {
		val.assign(n, 0); comp.assign(n, -1);
		Time = ncomps = 0;
		for (int i = 0; i < n; i++) {
			if (comp[i] < 0) dfs(i, g, f);
		}
	}
}

typedef long long ll;

template <class T = int>
T gcd(T a, T b) {
	if (b == 0) {
		return (a < 0 ? -a : a);
	}
	return gcd(b, a % b);
}

using DSU = DisjointSetUnion;

struct E {
	int dest, len;
};

struct E2 {
	int from, dest, len;
};

#ifdef DEBUG
const int MAXN = 100;
#else
const int MAXN = 200005;
#endif

std::vector<E> edges[MAXN];
std::vector<int> dests[MAXN];
ll lengths[MAXN];
int visited[MAXN] = {};
ll gcds[MAXN] = {};

void dfs(int node, const std::vector<int> &nodes, ll &res) {
	visited[node] = 2;
	for (auto &e : edges[node]) {
		if (visited[e.dest] == 0) continue;
		if (visited[e.dest] == 2) {
			ll v = llabs(lengths[node] + e.len - lengths[e.dest]);
			if (v != 0) {
				if (res == 0) {
					res = v;
				}
				else {
					res = gcd(res, v);
				}
			}
			continue;
		}
		lengths[e.dest] = lengths[node] + e.len;
		dfs(e.dest, nodes, res);
	}
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b, l;
		scanf("%d %d %d", &a, &b, &l);
		edges[a].push_back({b, l});
		dests[a - 1].push_back(b - 1);
	}
	DSU dsu = DSU(n);
	SCC::scc(n, dests, [&](const std::vector<int> &nodes) {
		if (nodes.size() == 1) return;
		std::vector<int> nodes2 = nodes;
		for (int &v : nodes2) v++;
		for (int v : nodes2) {
			visited[v] = 1;
		}
		for (int i = 1; i < nodes2.size(); i++) {
			dsu.merge(nodes2[0], nodes2[i]);
		}
		ll res = 0;
		dfs(nodes2.front(), nodes2, res);
		gcds[dsu.findParent(nodes2[0])] = res;
		for (int v : nodes2) {
			visited[v] = 0;
		}
	});
	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		int v, s, t;
		scanf("%d %d %d", &v, &s, &t);
		int pa = dsu.findParent(v);
		if (s == 0) {
			printf("YES\n");
			continue;
		}
		if (gcds[pa] == 0) {
			printf("NO\n");
			continue;
		}
		ll g = gcd(gcds[pa], (ll)t);
		bool res = (t - s) % g == 0;
		printf("%s\n", res ? "YES" : "NO");
	}

	return 0;
}