Under construction

Still being built. Things may change

Freight Train

Interview

Time limit10sMemory limit1024 MB

Summary
Given Bitek's list as a subsequence of Bajtek's list, mark each wagon 1 if Bitek could have recorded it and 0 if he certainly missed it.
Level

Medium6 of 10

Topics
Two pointers, Binary search, Array
Solved
No attempts yet

Problem

Bajtek and Bitek enjoy watching trains that pass near their home. They love freight trains most, because those are usually very long and have varied wagons. The boys decided to record which types of wagons make up each train. For simplicity, the wagon types are numbered from 1 to kk. Wagons of the same type are indistinguishable to the boys.

When a train passes, both boys write down the types of the wagons in their notebooks, in order. Bajtek is older and can record the types of all wagons without mistakes. Bitek is younger and not yet as skilled at writing. Sometimes, before he manages to write down a wagon's type, the next wagons have already passed, and Bitek does not notice them. So some wagons may be missing from Bitek's list.

The boys are now analyzing their notes. They want to determine which wagons of the train Bitek could have recorded, and which ones he certainly missed.

Input

The first line contains three integers nn, mm, and kk (1≤n,m,k≤300 0001 \le n, m, k \le 300\,000), which are the length of Bajtek's list (equal to the number of wagons in the train), the length of Bitek's list, and the number of different wagon types.

The second line contains nn integers from [1,k][1, k], the wagon types on Bajtek's list. The third line contains mm integers in the same format, the list of Bitek's list.

You may assume that Bitek may have skipped some wagons from Bajtek's list, but he did not add anything extra. In other words, the input is such that some number of wagons (possibly zero) can be erased from Bajtek's list to obtain Bitek's list.

Output

Print nn integers separated by single spaces. The ii-th integer is 11 if the ii-th wagon could have been recorded by Bitek, or 00 if it certainly could not have been recorded.

Hint

Explanation of the example: Bitek could have recorded the wagons with these numbers:

  • 1, 2, 4, and 5,
  • 1, 2, 4, and 9,
  • 1, 2, 7, and 9,
  • 1, 6, 7, and 9,
  • or 4, 6, 7, and 9.

Examples1

  1. Example 1

    Input
    9 4 3
    1 3 2 1 2 3 1 3 2
    1 3 1 2
    
    Expected output
    1 1 0 1 1 1 1 0 1