for _ in range(int(input())): n, m = map(int, input().split()) G = [[] for i in range(n)] for _ in range(m): u, v = map(int, input().split()) G[u - 1].append(v - 1) G[v - 1].append(u - 1) s = set([len(G[i]) for i in range(n)]) print("Yes" if n - len(s) else "No")