import java.util.Scanner;
public class Main{
public static int[] list;
public static void main(String[] args){
int N, M, Z, X, Y;
try(Scanner scanner = new Scanner(System.in)){
N = scanner.nextInt();
M = scanner.nextInt();
list = new int[N + 1];
while(N > 0){
...