1515_G. Phoenix and Odometers
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>
```python
import sys
from sys import stdin
import math
from collections import deque

import sys
 
class scc_graph:
 
    def __init__(self, N):
        self.N = N
        self.edges = []
 
    def csr(self):
        self.start = [0]*(self.N+1)
        self.elist = [0]*len(self.edges)
        for e in self.edges:
            self.start[e[0]+1] += 1
        for i in range(1, self.N+1):
            self.start[i] += self.start[i-1]
        counter = self.start[:]
        for e in self.edges:
            self.elist[counter[e[0]]] = e[1]
            counter[e[0]] += 1
 
    def add_edge(self, v, w):
        self.edges.append((v, w))
 
    def scc_ids(self):
        self.csr()
        N = self.N
        now_ord = group_num = 0
        visited = []
        low = [0]*N
        order = [-1]*N
        ids = [0]*N
        parent = [-1]*N
        stack = []
        for i in range(N):
            if order[i] == -1:
                stack.append(i)
                stack.append(i)
                while stack:
                    v = stack.pop()
                    if order[v] == -1:
                        low[v] = order[v] = now_ord
                        now_ord += 1
                        visited.append(v)
                        for i in range(self.start[v], self.start[v+1]):
                            to = self.elist[i]
                            if order[to] == -1:
                                stack.append(to)
                                stack.append(to)
                                parent[to] = v
                            else:
                                low[v] = min(low[v], order[to])
                    else:
                        if low[v] == order[v]:
                            while True:
                                u = visited.pop()
                                order[u] = N
                                ids[u] = group_num
                                if u == v:
                                    break
                            group_num += 1
                        if parent[v] != -1:
                            low[parent[v]] = min(low[parent[v]], low[v])
        for i, x in enumerate(ids):
            ids[i] = group_num-1-x
 
        return group_num, ids
 
    def scc(self):
        group_num, ids = self.scc_ids()
        groups = [[] for _ in range(group_num)]
        for i, x in enumerate(ids):
            groups[x].append(i)
        return groups

"""
def SCC(N,M,elis):

    lis = [ [] for i in range(N) ]
    rlis = [ [] for i in range(N)]

    for u,v in elis:
        lis[u].append(v)
        rlis[v].append(u)

    stk = []
    nind = [0] * N
    visit = [False] * N
    leave = [None] * N
    nl = 0

    for loop in range(N):

        if visit[loop] == False:
            visit[loop] = True
            stk.append(loop)

            while stk:
                if nind[stk[-1]] >= len(lis[stk[-1]]):
                    leave[stk[-1]] = nl
                    nl += 1
                    del stk[-1]

                else:
                    nexv = lis[stk[-1]][nind[stk[-1]]]
                    nind[stk[-1]] += 1
                    if not visit[nexv]:
                        stk.append(nexv)
                        visit[nexv] = True


    visit = [False] * N
    mv = [ (leave[i],i) for i in range(N) ]
    mv.sort()
    ret = []

    while mv:

        tmp,v = mv[-1]
        del mv[-1]

        if not visit[v]:

            visit[v] = True
            q = [v]
            nlinks = []

            while q:
                x = q[-1]
                del q[-1]
                nlinks.append(x)

                for nex in rlis[x]:
                    if not visit[nex]:
                        visit[nex] = True
                        q.append(nex)

            ret.append(nlinks)
    return ret
"""

n,m = map(int,stdin.readline().split())
N = n

sg = scc_graph(n)

lis = [ [] for i in range(n)]
elis = []
for i in range(m):
    a,b,l = map(int,stdin.readline().split())
    a -= 1
    b -= 1
    
    lis[a].append((b,l))
    sg.add_edge(a,b)

SC = sg.scc()
sclis = [None] * N
for i in range(len(SC)):
    for j in SC[i]:
        sclis[j] = i

scgcd = [None] * len(SC)
d = [None] * N

for i in range(N):

    if scgcd[sclis[i]] == None:

        ngcd = float("inf")
        q = deque([i])
        d[i] = 0

        while q:
            v = q.popleft()

            for nex,l in lis[v]:
                if sclis[nex] == sclis[v]:
                    if d[nex] == None:
                        d[nex] = d[v] + l
                        q.append(nex)
                    elif abs(d[nex]-d[v]-l) != 0:
                        if ngcd == float("inf"):
                            ngcd = abs(d[nex] - d[v]-l)
                        else:
                            ngcd = math.gcd(ngcd,abs(d[nex]-d[v]-l))

        scgcd[sclis[i]] = ngcd

q = int(stdin.readline())
ANS = []

#print (SC)
#print (scgcd)

for loop in range(q):

    vi,si,ti = map(int,stdin.readline().split())
    vi -= 1

    if scgcd[sclis[vi]] == float("inf"):
        if si == 0:
            ANS.append("YES")
        else:
            ANS.append("NO")
    else:
        if ((-1*si) % ti) % math.gcd(scgcd[sclis[vi]] , ti) == 0:
            ANS.append("YES")
        else:
            ANS.append("NO")

print ("\n".join(ANS))
```