using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using System.Threading; using System.Runtime.CompilerServices; //using nint=System.Int32; static class Program{ const int mod=(int)1e9+7; //const double eps=1e-11; static void Main(){ Sc sc=new Sc(); var b=new BigInteger[3]; var m=new BigInteger[3]; for(int i = 0;i<3;i++) { var e=sc.Ia; b[i]=e[0]; m[i]=e[1]; } var ans=Cr(b,m); Console.WriteLine(ans.Item1!=0?ans.Item1:ans.Item2); } static (BigInteger,BigInteger) Cr(BigInteger[] b,BigInteger[] m) { BigInteger bz=0,mz=1; for(int i = 0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i