cho.sh
Notes
Loading...

Martial Arts Practice

Time limit

2s

Memory limit

128 MB

Problem

Students practice martial arts so their bodies do not grow weak. One representative exercise is archery. In this exercise, they do not use a special target; instead, students standing in the opposite row serve as targets.

The students stand in two long rows. Each student looks at exactly one student in the opposite row. Some students will hold bows, and the remaining students will hold shields.

No one may be injured during practice. Therefore, if a student holding a bow looks at someone in the opposite row, that target must hold a shield. Also, no student may hold a shield unnecessarily. In other words, every student holding a shield must be aimed at by at least one bow-holding student from the opposite row.

Given whom each student in the two rows is looking at, output whether each student should hold a bow or a shield.

Input

The first line contains two positive integers m and n. (1 ≤ m, n ≤ 50,000) This means that row A has m students and row B has n students.

The students in row A are numbered from 1 to m in order, and the students in row B are numbered from 1 to n in order.

The second line contains m integers. The k-th integer is the number of the student in row B that student k in row A is looking at.

The third line contains n integers. The k-th integer is the number of the student in row A that student k in row B is looking at.

Output

On the first line, output a string of length m describing the choices for row A. If the k-th character is 1, student k in row A holds a bow; if it is 0, that student holds a shield.

On the second line, output a string of length n describing the choices for row B in the same way.

You may output any assignment that satisfies the conditions.