Monk visits Biksy, the largest trading market in the land. Biksy has traders from all over the world.
There are a total of N items indexed from 1 to N, that are traded in the market by a total of M dealers. Each trader is characterized by three integers, say i, j, C , meaning that the trader will take i'th item from you and give you j'th item and C units of money. A negative value of C signifies that, in order to get j'th item from the trader, you will have to give i'th item and C units of money.  Note that there can be multiple dealers who deal with the same pair of items and some crazy dealers might trade the same item as well i.e. (i = j).
Monk visits Biksy having the item number 1. He collects the data of all the traders and wants to know if there is way by which he can become infinity rich if he acts smart! i.e. if there are a series of profits, repeating which, will always increase the number of units of money with him! Help Monk find the answer to this question. Note that Monk can go to any dealer any number of times. 

Input:
First line contains an integer T. T test cases follow.
First line of each test case contains two space-separated integers N, M
Next M lines contain three space-separated integers i, j and C, the characteristics of the traders.

Output:
Print "Yes"(without the quotes) if such a way exists, "No"(without the quotes) otherwise.
Print the answer to each test case in a new line. 

Constraints: 
1 ≤ T ≤ 10
1 ≤ N ≤ 100 
1 ≤ M ≤ 1000
1  ≤ i, j ≤ N
-1000 ≤ C ≤ 1000  

SAMPLE INPUT
2
5 6
1 2 2
2 3 -1
3 4 -7
4 5 0
2 3 -7
3 5 6
5 8
1 5 10
2 3 -6
5 2 5
4 5 9
1 5 1
2 4 -10
2 3 -2
4 1 1

SAMPLE OUTPUT
No
Yes

Explanation

For the first test case, there is no such way possible.
For the second test case,  Monk starts with item 1.
Trades it for 5th item gaining 10 units.
Trades 5th for 2nd gaining 5 units.
Trades 2nd for 4th losing 10 units.
Trades 4th for 1st gaining 1 unit.
Thereby, gaining 6 units in this process and it can be repeated indefinitely to make Monk infinitely rich!
from collections import defaultdict
import sys
T = int(raw_input())
inf = sys.maxint
for test in range(T):
    N,M = [int(x) for x in raw_input().split()]
    D   = [[inf]*(N+1) for x in range(N+1) ]
    dicti = defaultdict(lambda :-1*inf)
    for l in range(M):
        i,j,c = [int(x) for x in raw_input().split()]
        if dicti[(i,j)] < c:
            dicti[(i,j)] = c

    #print dicti
    for i in range(1,N+1):
        D[i][i] = 0
        
    for key,value in dicti.iteritems():
        D[key[0]][key[1]] = -1*value
        
        
    '''    
    for i in range(N):
    	if D[i][i]>0:
    		D[i][i]=0
    '''

    #for i in range(N):
        #print D[i]

    for k in range(1,N+1):
        for i in range(1,N+1):
            for j in range(1,N+1):
                if D[i][k] == inf or D[k][j]==inf:
                    continue
                elif D[i][j] > D[i][k]+D[k][j]:
                      D[i][j] = D[i][k]+D[k][j]
    
  	flag = 0
    for i in range(1,N+1):
    	if D[i][i] < 0 and D[1][i]!=inf : 
    		print "Yes"
    		flag = 1
    		break
    if flag == 0:
    	print "No"