import java.math.BigInteger; import java.util.*; public class Main { public static void main(String []args) { Scanner cin=new Scanner(System.in); int n,m,i; int t1=0; while(cin.hasNextBigInteger()) { t1++; m=cin.nextInt(); n=cin.nextInt(); if(m==0&&am…