mapfile a $[x[x=1]=${a[1]// /,x*=},x*=${a[3]// /,x[i=!i]*=},y=x[1],f=2] $[x%f|y%f?++f:(x/=f,y/=f)]{A..R} echo $[x<0?x=-x,-y:y] $x