q=int(input()) for _ in range(q): n,m,k=map(int,input().split()) comk = [[m for _ in range(n)]for _ in range(n)] for _ in range(m): a,b=map(int,input().split()) for i in range(n): comk[i][a-1]-=1 comk[i][b-1]-=1 comk[a-1][i]-=1 comk[b-1][i]-=1 comk[a-1][a-1]+=1 comk[b-1][b-1]+=1 comk[a-1][b-1]+=1 comk[b-1][a-1]+=1 # print(comk) l=[i+1 for i in range(n) if comk[i][i]==0] if l: print(1,len(l)) print(*l) else: mins=[min(row)+2 for row in comk] mi=min(mins) if mi>k: print(-1) else: l=[i+1 for i in range(n) if mins[i]==mi] print(mi, len(l)) print(*l)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | q=int(input()) for _ in range(q): n,m,k=map(int,input().split()) comk = [[m for _ in range(n)]for _ in range(n)] for _ in range(m): a,b=map(int,input().split()) for i in range(n): comk[i][a-1]-=1 comk[i][b-1]-=1 comk[a-1][i]-=1 comk[b-1][i]-=1 comk[a-1][a-1]+=1 comk[b-1][b-1]+=1 comk[a-1][b-1]+=1 comk[b-1][a-1]+=1 # print(comk) l=[i+1 for i in range(n) if comk[i][i]==0] if l: print(1,len(l)) print(*l) else: mins=[min(row)+2 for row in comk] mi=min(mins) if mi>k: print(-1) else: l=[i+1 for i in range(n) if mins[i]==mi] print(mi, len(l)) print(*l) |