#1034
Unrated
KOLO
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Adrian Satja Kurdija

Mirko has recently bought a wheel of fortune. He wrote an uppercase letter of English alphabet onto each wedge, like this (3rd example test case):

No letter appears twice in the wheel, and the wheel spins in clockwise direction. There is a pointer that stays in the same place while the wheel is spinning (it is pointing to H in the picture above). When we spin the wheel, the letter to which the pointer is pointing to changes accordingly. Mirko spinned the wheel K times in a row, and each time he wrote down how many times the pointed letter changed, and what letter was pointed to at the end of that spin. Slavko found that paper, and would like to now what letters Mirko wrote onto the wedges of the wheel. Help him determine this, if the total number of wedges is known.

입력

The first line of input contains integers N (2 ≤ N ≤ 25), the number of wedges on the wheel, and K (1 ≤ K ≤ 100), the number of spins. The following K lines contain descriptions Mirko wrote down for each spin, in order. Each line contains an integer S (1 ≤ S ≤ 100), the number of times the pointed letter changed during that spin, and an uppercase letter at which pointer stopped.

출력

If there is no wheel that meets the requirements described, output ‘!’. Otherwise, output sequence of letters written onto the wheel, starting from the pointed letter at the end of the last spin and proceeding clockwise. If some letter can’t be determined, output ‘?’ instead. Author: Adrian Satja Kurdija

예제 입력 1

3 3
1 A
2 B
3 C

예제 출력 1

!

예제 입력 2

5 6
1 A
2 B
5 B
1 C
2 A
2 B

예제 출력 2

B?A?C

예제 입력 3

8 8
4 V
3 I
7 T
7 A
6 R
5 N
1 O
9 H

예제 출력 3

HONITAVR
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.