atcoder#ARC151A. [ARC151A] Equal Hamming Distances

[ARC151A] Equal Hamming Distances

Score : 300300 points

Problem Statement

Below, a 0101-sequence is a string consisting of 0 and 1.

You are given two 0101-sequences SS and TT of length NN each. Print the lexicographically smallest 0101-sequence UU of length NN that satisfies the condition below.

  • The Hamming distance between SS and UU equals the Hamming distance between TT and UU.

If there is no such 0101-sequence UU of length NN, print 1-1 instead.

What is Hamming distance?

The Hamming distance between 0101-sequences X=X1X2XNX = X_1X_2\ldots X_N and Y=Y1Y2YNY = Y_1Y_2\ldots Y_N is the number of integers 1iN1 \leq i \leq N such that XiYiX_i \neq Y_i.

What is lexicographical order?

A 0101-sequence X=X1X2XNX = X_1X_2\ldots X_N is lexicographically smaller than a 0101-sequence Y=Y1Y2YNY = Y_1Y_2\ldots Y_N when there is an integer 1iN1 \leq i \leq N that satisfies both of the conditions below.

  • X1X2Xi1=Y1Y2Yi1X_1X_2\ldots X_{i-1} = Y_1Y_2\ldots Y_{i-1}.
  • Xi=X_i = 0 and Yi=Y_i = 1.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • NN is an integer.
  • SS and TT are 0101-sequences of length NN each.

Input

The input is given from Standard Input in the following format:

NN

SS

TT

Output

Print the lexicographically smallest 0101-sequence UU of length NN that satisfies the condition in the Problem Statement, or 1-1 if there is no such 0101-sequence UU.

5
00100
10011
00001

For U=U = 00001, the Hamming distance between SS and UU and the Hamming distance between TT and UU are both 22. Additionally, this is the lexicographically smallest 0101-sequence UU of length NN that satisfies the condition.

1
0
1
-1

No 0101-sequence UU of length NN satisfies the condition, so 1-1 should be printed.