CF2145B.Deck of Cards

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Deck of Cards

Monocarp has a deck of cards numbered from 11 to nn. Initially, the cards are arranged from smallest to largest, with 11 on top and nn at the bottom.

Monocarp performed kk actions on the deck. Each action was one of three types:

  • remove the top card;
  • remove the bottom card;
  • remove either the top or bottom card.

Your task is to determine the fate of each card: whether it remains in the deck, has been removed, or might be both.

Input

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases.

The first line of each test case contains two integers nn and kk (1kn21051 \le k \le n \le 2 \cdot 10^5).

The second line contains a string ss of length kk, consisting of characters 0, 1, and/or {2}. This string describes Monocarp's actions. If the ii-th character is 0, Monocarp removes the top card on the ii-th action. If it's 1, he removes the bottom card. If it's 2, either the top or bottom card can be removed.

Additional constraint on the input: the sum of nn over all test cases doesn't exceed 21052 \cdot 10^5.

Output

For each test case, print a string consisting of nn characters. The ii-th character should be + (plus sign) if the ii-th card is still in the deck, - (minus sign) if it has been removed, or ? (question mark) if its state is unknown.

Samples

4
4 2
01
3 2
22
1 1
2
7 5
01201
-++-
???
-
--?+?--

在线编程 IDE

建议全屏模式获得最佳体验