int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int a[maxn][maxn],x[maxn];
int equ,var;
int Gauss()
{
int i,j,k,max_r,col;
int LCM,tmp,ta,tb;
for(i=0;i<=var;i++) x[i]=0;
for(k=0,col=0;kabs(a[max_r][col])) max_r=i;
if(a[max_r][col]==0) { k--; continue; }
if(max_r!=k) for(j=k;j<=var;j++) swap(a[max_r][j],a[k][j]);
for(i=k+1;i=0;i--)
{
tmp=a[i][var];
for(j=i+1;j