T = int(input()) for i in range(T): n,m=map(int,input().split()) for i in range(m): input() print(n-1)