#include using namespace std; template pairginv(T a,T m){ T b=a,u=0,v=1; a=m; while(b){ T q=a/b; a-=q*b,swap(a,b); u-=q*v,swap(u,v); } if(u<0)u+=m/a; return{a,u}; } template paircrt(T a,T m,T b,T n){ if(m>a>>b>>c>>d>>e>>f; tie(a,b)=crt(a,b,c,d); tie(a,b)=crt(a,b,e,f); if(a==0)a+=b; if(b==0)cout<<-1<<'\n'; else cout<