# your code goes here
from itertools import product
def mix(first,second):
if not (bool(first) and bool(second)):
return first+second
el = next(product(first,second))
if el[0] == el[1]:
del first[first.index(el[0])], second[second.index(el[0])]
return mix(first,second)
x = mix([1,1,1,1],[1,1])
print(x)
IyB5b3VyIGNvZGUgZ29lcyBoZXJlCmZyb20gaXRlcnRvb2xzIGltcG9ydCBwcm9kdWN0CmRlZiBtaXgoZmlyc3Qsc2Vjb25kKToKCWlmIG5vdCAoYm9vbChmaXJzdCkgYW5kIGJvb2woc2Vjb25kKSk6CgkJcmV0dXJuIGZpcnN0K3NlY29uZAoJZWwgPSBuZXh0KHByb2R1Y3QoZmlyc3Qsc2Vjb25kKSkKCWlmIGVsWzBdID09IGVsWzFdOgoJCWRlbCBmaXJzdFtmaXJzdC5pbmRleChlbFswXSldLCBzZWNvbmRbc2Vjb25kLmluZGV4KGVsWzBdKV0KCXJldHVybiBtaXgoZmlyc3Qsc2Vjb25kKQoJCgp4ID0gbWl4KFsxLDEsMSwxXSxbMSwxXSkKcHJpbnQoeCk=