from sys import stdin input=lambda :stdin.readline()[:-1] def solve(): n=int(input()) cnt=[0]*n for i in range(n-1): a,b=map(lambda x:int(x)-1,input().split()) cnt[a]+=1 cnt[b]+=1 one=cnt.count(1) if n-one<=one: print('Yes') else: print('No') for _ in range(int(input())): solve()