class Solution(object):
def mostFrequentEven(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
d = collections.Counter()
for num in nums:
if num % 2 == 0:
d[num] += 1
ans, cnt = -1, 0
for k, v in d.items():
if v > cnt or (v == cnt and k < ans):
ans = k
cnt = v
return ans