import collections T = int(input()) for _ in range(T): N,M = map(int, input().split()) L = [0]*N for _ in range(M): a,b = map(int, input().split()) L[a-1]+=1 L[b-1]+=1 C = collections.Counter(L) for v in C.values(): if v>=2: print('Yes') break else: print('No')