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 mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 210000;
vector<pii> e[maxn], re[maxn];
int vis[maxn];
int comp[maxn];
i64 p[maxn], G[maxn];

i64 GCD(i64 a, i64 b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

vi ord;

void dfs0(int v) {
    if (vis[v]) return;
    vis[v] = 1;
    for (auto [u, l]: e[v]) dfs0(u);
    ord.pb(v);
}

void dfs_re(int v, int c) {
    if (comp[v] != -1) return;
//    cerr << v << ' ' << c << '\n';
    comp[v] = c;
    for (auto [u, l]: re[v]) {
        dfs_re(u, c);
    }
}

void dfs_G(int v, int c, i64 w) {
    if (comp[v] != c) return;
    if (vis[v]) {
        G[c] = GCD(G[c], abs(w - p[v]));
        return;
    }
    p[v] = w;
    vis[v] = 1;
    for (auto [u, l]: e[v]) dfs_G(u, c, w + l);
    for (auto [u, l]: re[v]) dfs_G(u, c, w - l);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, m;
    cin >> n >> m;
    forn(i, m) {
        int u, v, l;
        cin >> u >> v >> l;
        --u; --v;
        e[u].pb({v, l});
        re[v].pb({u, l});
    }

    forn(i, n) dfs0(i);
    
    reverse(all(ord));
    forn(i, n) comp[i] = -1, vis[i] = 0;
    int C = 0;
    for (int v: ord) {
        if (comp[v] != -1) continue;
        dfs_re(v, C);
        dfs_G(v, C, 0);
        ++C;
    }

//    forn(i, n) cerr << G[comp[i]] << '\n';

    int q;
    cin >> q;
    while (q--) {
        int v, s, t;
        cin >> v >> s >> t;
        --v;
        cout << (s % GCD(G[comp[v]], t) == 0 ? "YES" : "NO") << '\n';
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}