%%%%%%%%%%%%%%%%%%%%%%%  
%%  chin  -  Chinese remainder THM
function  z=chin(x1,b1,x2,b2)
x1=mod(x1,b1);  x2=mod(x2,b2);
z2=lcm(b1,b2);  [z3 u v]=gcd(b2,b1);
if x2
   z=chin(x1-x2,b1,0,b2);
   if length(z), z(1)=mod(z(1)+x2,z2);  end
   return
end
if  mod(x1,z3)~=0,   z=[]; return, end
z1=mod(u*x1*b2/z3,z2);
z=[z1 z2];
