import collections def main(): t = int(input()) for _ in range(t): n, m = map(int, input().split()) if n == 1: print("YES") continue d = collections.defaultdict(set) for _ in range(m): fr, to = map(int, input().split()) d[fr].add(to) d[to].add(fr) lst = list(map(len, dict(d).values())) if len(set(lst)) != n: print("Yes") else: print("No") if __name__ == "__main__": main()