Under construction

Still being built. Things may change

Dramatic Duel

Time limit1sMemory limit512 MB

Summary
Given n carpet kinds and k stacked carpets, the task is to pick each carpet's orientation so the guide, who moves first, loses, or report that no such placement exists.
Level

Hard8 of 10

Topics
Game theory, Dynamic programming, Sorting
Solved
No attempts yet

Problem

Noon. A meadow stands in front of a photogenic building named after Heydar Aliyev. Mr. Malnar, the protagonist of this anecdote, orders his loyal squad of Olympians to flip over. At that moment, a brave gentleman hurries toward Mr. Malnar. He is the guide of the Croatian team and also the antagonist. Nobody knew that this was the start of an epic clash people would talk about for years.

To settle the clash, they agreed to play a game. Azerbaijan has nn kinds of rectangular carpets, and the ii-th kind has sides S and D of lengths sis_i and did_i. Each player has an unlimited supply of carpets of every kind.

The game starts with Mr. Malnar placing exactly kk carpets on the ground, so that the ii-th carpet placed is of kind aia_i. For each carpet, Mr. Malnar chooses whether side S or side D is parallel to the equator.

The players take turns, starting with the guide. The player who cannot make a move loses. On a move, a player takes a fresh carpet of any kind and places it on top of one of the kk stacks on the ground. The carpet is placed with side S parallel to the equator, and it must lie completely on the carpet beneath it. In other words, when carpet PP is placed on carpet QQ, the side of PP parallel to the equator must be strictly less than the side of QQ parallel to the equator, and the side of PP perpendicular to the equator must be strictly less than the side of QQ perpendicular to the equator.

Mr. Malnar played perfectly, and so did his opponent, to everyone's surprise. The records of the duel preserve the values sis_i and did_i for every kind and the kinds of all kk carpets that were on the ground. The only unknown is how Mr. Malnar oriented the first kk carpets. Find one way to place the first kk carpets that guarantees him a win.

Input

The first line contains integers nn and kk (1≤n,k≤1051 \leq n, k \leq 10^5).

Each of the next nn lines contains two integers sis_i and did_i (1≤si,di≤1051 \leq s_i, d_i \leq 10^5). No two carpets have the same width, and no two carpets have the same length.

The last line contains kk integers aia_i (1≤ai≤n1 \leq a_i \leq n).

Output

If Mr. Malnar cannot win no matter how he places the first kk carpets, print nemoguce on a single line. Otherwise, print a string of kk characters, each 0 or 1, on a single line. If the ii-th character is 1, Mr. Malnar placed the ii-th carpet with side D parallel to the equator. If it is 0, he placed it with side S parallel to the equator.

Examples2

  1. Example 1

    Input
    5 3
    1 1
    2 3
    4 2
    3 4
    5 5
    1 3 4
    
    Expected output
    001
    
  2. Example 2

    Input
    5 3
    1 1
    2 3
    4 2
    3 4
    5 5
    1 2 5
    
    Expected output
    nemoguce