Types: N: int, a: List[Union[int, str]]
Ranges: 2 ≤ N ≤ 1,000, -10^9 ≤ a[i] ≤ 10^9 or a[i] = 'x'
Addtl Info: The number of datasets does not exceed 100. Input ends with a single '0'.