let d_rec a b = 
  if (fst a) >= (snd b) && (snd a) >= (fst b) then 
    ((fst a) - (snd b), snd a) 
  else raise (Beam_Matching_Error "rec")