/* 全く分からない */ package no187a; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { static long MOD = 1000000007; static IO io = new IO(); public static void main(String[] args) { int n = io.nextInt(); BigInteger[] a = new BigInteger[n]; BigInteger[] b = new BigInteger[n]; BigInteger[] m = new BigInteger[n]; for(int i=0;i 0) { System.out.println(x[1]); }else{ System.out.println(-1); } }else{ System.out.println((x[0].remainder(x[1]).add(x[1])).remainder(x[1])); } } } class Mod { public static BigInteger[] linearCongruence(BigInteger[] A,BigInteger[] B,BigInteger[] M) { BigInteger x = BigInteger.ZERO; BigInteger m = BigInteger.ONE; for(int i=0;i Integer.MAX_VALUE) { throw new NumberFormatException(); } return (int) nl; } public char nextChar() { if (!hasNext()) { throw new NoSuchElementException(); } return (char) readByte(); } public double nextDouble() { return Double.parseDouble(next());} public int[] nextIntArray(int n) { int[] a = new int[n]; for(int i=0;i