哪位大佬看看这样行不行
import java.util.HashSet;
import java.util.Scanner;
public class main3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
int [] res = new int[T];
for(int k=0;k<T;++k){
int n = sc.nextInt();
int m = sc.nextInt();
HashSet<Integer> set1 = new HashSet<>();
HashSet<Integer> set2 = new HashSet<>();
for(int i=0;i<m;++i){
int x = sc.nextInt();
int y = sc.nextInt();
if(x==1 || y==1){
set1.add(x+y-1);
}
else if(x==n || y==n){
set2.add(x+y-n);
}
}
for(int c:set1){
if(set2.contains(c)){
res[k]=1;
}
}
}
for(int c:res){
if(c==1){
System.out.println("POSSIBLE");
}
else {
System.out.println("IMPOSSIBLE");
}
}
}
}