let z=List.fold_left2 and k=[0;1;2;3]and h()=Scanf.scanf"%d %d %d %d "(fun a b c d->[a;b;c;d]);;
let rec f()=
  let a,b=h(),h()in
  let m,n=z(fun(m,n)s i->z(fun(p,q)x j->if x=s&&i=j then(p+1,q)else if x<>s then(p,q)else(p,q+1))(m,n)a k)(0,0)b k in
  f(Printf.printf "%d %d\n"m n);;
try f()with _->()