class Solution(object):
def flipgame(self, fronts, backs):
"""
:type fronts: List[int]
:type backs: List[int]
:rtype: int
"""
n = len(fronts)
same = set()
for i in range(n):
if fronts[i] == backs[i]:
same.add(fronts[i])
ans = float("inf")
for i in range(n):
if fronts[i] not in same and fronts[i] < ans:
ans = fronts[i]
if backs[i] not in same and backs[i] < ans:
ans = backs[i]
return ans if ans != float("inf") else 0