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 JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskG solver = new TaskG();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskG {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            SCCGraph g = new SCCGraph(n);
            SCCGraph gR = new SCCGraph(n);
            for (int i = 0; i < m; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                int c = in.nextInt();
                g.addEdge(a, b, c);
                gR.addEdge(b, a, c);
            }

            g.findSCC();
            gR.findSCC();

            long[] depth = new long[n];
            int[] col = new int[n];
            long[] compGcd = new long[g.numComps];
            long[] up = new long[n];
            long[] depthR = new long[n];
            Arrays.fill(depthR, -1);
            for (int i = 0; i < n; i++) {
                if (col[i] == 0) {
                    depthR[i] = 0;
                    dfsDepth(gR, i, depthR);
                    dfs(g, i, depth, depthR, col, compGcd, up);
                }
            }

            int numQueries = in.nextInt();
            for (int query = 0; query < numQueries; query++) {
                int v = in.nextInt() - 1;
                long s = in.nextInt();
                int t = in.nextInt();
                long d = compGcd[g.comp[v]];
                out.println((t - s) % gcd(d, t) == 0 ? "YES" : "NO");
            }
        }

        private void dfsDepth(SCCGraph g, int v, long[] depth) {
            for (int e = g.firstEdge[v]; e >= 0; e = g.edgeNxt[e]) {
                int u = g.edgeDst[e];
                if (g.comp[v] != g.comp[u]) {
                    continue;
                }
                if (depth[u] < 0) {
                    depth[u] = depth[v] + g.edgeWeight[e];
                    dfsDepth(g, u, depth);
                }
            }
        }

        private void dfs(SCCGraph g, int v, long[] depth, long[] depthR, int[] col, long[] compGcd, long[] up) {
            col[v] = 1;
            for (int e = g.firstEdge[v]; e >= 0; e = g.edgeNxt[e]) {
                int u = g.edgeDst[e];
                if (g.comp[v] != g.comp[u]) {
                    continue;
                }
                if (col[u] == 0) {
                    depth[u] = depth[v] + g.edgeWeight[e];
                    dfs(g, u, depth, depthR, col, compGcd, up);
                } else {
                    up[v] = gcd(up[v], depth[v] + g.edgeWeight[e] + depthR[u]);
                }
            }
            compGcd[g.comp[v]] = gcd(compGcd[g.comp[v]], up[v]);
            col[v] = 2;
        }

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

        class SCCGraph {
            int n;
            int numComps;
            int[] low;
            int[] vis;
            int[] comp;
            boolean[] onStack;
            int[] stack;
            int sp;
            int globalTime;
            int numEdges;
            int[] firstEdge;
            int[] edgeDst = new int[10];
            int[] edgeNxt = new int[10];
            int[] edgeWeight = new int[10];

            SCCGraph(int n) {
                this.n = n;
                vis = new int[n];
                low = new int[n];
                stack = new int[n];
                comp = new int[n];
                onStack = new boolean[n];
                firstEdge = new int[n];
                clear();
            }

            public void clear() {
                Arrays.fill(firstEdge, -1);
                numEdges = 0;
            }

            private void addEdge(int a, int b, int c) {
                int e = numEdges++;
                if (e >= edgeDst.length) {
                    int k = edgeDst.length;
                    edgeDst = Arrays.copyOf(edgeDst, k * 3 / 2 + 1);
                    edgeNxt = Arrays.copyOf(edgeNxt, k * 3 / 2 + 1);
                    edgeWeight = Arrays.copyOf(edgeWeight, k * 3 / 2 + 1);
                }
                edgeDst[e] = b;
                edgeNxt[e] = firstEdge[a];
                edgeWeight[e] = c;
                firstEdge[a] = e;
            }

            public void findSCC() {
                Arrays.fill(vis, -1);
                Arrays.fill(onStack, false);
                sp = 0;
                globalTime = 0;
                numComps = 0;
                for (int i = 0; i < n; i++) {
                    if (vis[i] < 0) {
                        dfsTarjan(i);
                    }
                }
            }

            void dfsTarjan(int v) {
                vis[v] = globalTime;
                low[v] = globalTime;
                ++globalTime;
                stack[sp++] = v;
                onStack[v] = true;
                for (int e = firstEdge[v]; e >= 0; e = edgeNxt[e]) {
                    int u = edgeDst[e];
                    if (vis[u] < 0) {
                        dfsTarjan(u);
                        if (low[v] > low[u]) {
                            low[v] = low[u];
                        }
                    } else if (onStack[u] && low[v] > vis[u]) {
                        low[v] = vis[u];
                    }
                }
                if (low[v] == vis[v]) {
                    while (true) {
                        int u = stack[--sp];
                        onStack[u] = false;
                        comp[u] = numComps;
                        if (u == v) {
                            break;
                        }
                    }
                    ++numComps;
                }
            }

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}