第一行一个数表示数据组数
每组数据第一行两个数。含义见题意。
接下来m行每行两个数表示
到
之间有一条边
每组数据一行如果能回到公司输出“POSSIBLE”,不能输出"IMPOSSIBLE"。
1 4 3 1 2 2 3 3 4
IMPOSSIBLE
T=int(input())
for t in range(T):
n,m=list(map(int,input().split()))
s1,s2=set(),set()
for i in range(m):
a,b=list(map(int,input().split()))
if a==1:
s1.add(b)
if b==n:
s2.add(a)
if len(s1&s2)>0 or n in s1 or 1 in s2:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
大佬们,为啥不对呢,样例也看不到