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;
using ll = long long;

const int sz = 200005;

struct nodetype {
public:
    int l;
    void init(int node1, int node2, int length) {
        n1 = node1;
        n2 = node2;
        l = length;
    }
    int othernode(int node) {
        if (node == n1) return n2;
        else if (node == n2) return(n1);
        else return(-1);
    }
private:
    int n1, n2;
} nodearr[sz];

vector<int> adj[sz], revadj[sz];

int visited[sz] = {}, nodestk[sz] = {}, congrp[sz] = {};
ll mydist[sz] = {}, gcdarr[sz] = {};

int visit(int node, int& marker, ll dist) {
    if (visited[node]) return(-1);
    visited[node] = 1;
    mydist[node] = dist;
    for (auto& i: adj[node]) {
        visit(nodearr[i].othernode(node), marker, dist + nodearr[i].l);
    }
    marker++;
    nodestk[marker] = node;
    return(0);
}

int group(int node, int root) {
    if (congrp[node] != 0) return(-1);
    congrp[node] = root;
    for (auto& i: revadj[node]) {
        group(nodearr[i].othernode(node), root);
    }
    return(0);
}

ll findgcd(ll n, ll m) {
    while (m != 0) {
        ll t = n;
        n = m;
        m = t % m;
    }
    return(abs(n));
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);//cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int t1, t2, t3;
        //cin >> t1 >> t2 >> t3;
        scanf("%d %d %d", &t1, &t2, &t3);
        nodearr[i].init(t1, t2, t3);
        adj[t1].push_back(i);
        revadj[t2].push_back(i);
    }
    int marker = 0;
    for (int i = 1; i <= n; i++) visit(i, marker, 0);
    for (int i = n; i >= 1; i--) {
        if (congrp[nodestk[i]] == 0) {
            group(nodestk[i], nodestk[i]);
        }
    }
    for (int i = 1; i <= n; i++) {
        int groupid = congrp[i];
        int node1 = i;
        for (auto& j: adj[node1]) {
            int node2 = nodearr[j].othernode(i);
            if (congrp[node2] == groupid) {
                gcdarr[groupid] = findgcd(gcdarr[groupid], mydist[node1] - mydist[node2] + nodearr[j].l);
            }
        }
    }

    //for (int i = 1; i <= n; i++) cout << nodestk[i];
    //for (int i = 1; i <= n; i++) cout << congrp[i];

    int q;
    scanf("%d", &q);
    for (int i = 1; i <= q; i++) {
        int v, s, t;
        //cin >> v >> s >> t;
        scanf("%d %d %d", &v, &s, &t);
        ll g = findgcd(gcdarr[congrp[v]], t);
        if ((g == 0 && s == 0) || (g != 0 && s % g == 0))
            printf("YES\n");
        else
            printf("NO\n");
            //cout << "YES\n"; else cout << "NO\n";
    }
    return(0);
}