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 namespace std;
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define loop(i, a) for (int i = 0; i < (a); ++i)
#define cont(i, a) for (int i = 1; i <= (a); ++i)
#define circ(i, a, b) for (int i = (a); i <= (b); ++i)
#define range(i, a, b, c) for (int i = (a); (c) > 0 ? i <= (b) : i >= (b); i += (c))
#define parse(it, x) for (auto &it : (x))
#define pub push_back
#define pob pop_back
#define emb emplace_back
#define mak make_pair
#define mkt make_tuple
typedef long long ll;
typedef long double lf;
const int Inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;

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

int n, m;
vector<pair<int, int> > nei[200005];
int dfn[200005], low[200005], tmc;
vector<int> stk;
bool lgl[200005];
ll hg[200005], de[200005];
int bel[200005], cs;
ll gs[200005];

void tarjan(int now, ll dep) {
    stk.pub(now); lgl[now] = 1;
    dfn[now] = low[now] = ++tmc;
    de[now] = dep;
    parse(it, nei[now]) {
        int to = it.first;
        if (!dfn[to]) {
            tarjan(to, dep + it.second);
            low[now] = min(low[now], low[to]);
        } else if (lgl[to]) {
            hg[now] = gcd(hg[now], de[now] - de[to] + it.second);
            low[now] = min(low[now], dfn[to]);
        }
    }
    if (dfn[now] == low[now]) {
        bel[now] = ++cs;
        lgl[now] = 0;
        while (stk.back() != now) {
            int to = stk.back();
            bel[to] = cs;
            lgl[to] = 0;
            stk.pob();
        }
        stk.pob();
    }
}

int main() {
    scanf("%d%d", &n, &m);
    cont(i, m) {
        int a, b, l; scanf("%d%d%d", &a, &b, &l);
        nei[a].emb(b, l);
    }
    cont(i, n) if (!dfn[i]) tarjan(i, 0);
    cont(i, n) gs[bel[i]] = gcd(gs[bel[i]], hg[i]);
    int q; scanf("%d", &q);
    while (q--) {
        int v, s, t; scanf("%d%d%d", &v, &s, &t);
        int rem = (t - s) % t;
        ll gg = gcd(gs[bel[v]], t);
        if (!rem || (gg && rem % gg == 0)) puts("YES");
        else puts("NO");
    }
    return 0;
}