Guessing Passwords
문제
Ingfríður is testing her new pet project website, Passwordle. The rules should be rather familiar for those who have played plenty of wordle, but let us review them here. The website picks a secret password that the user then has to guess. The password will be characters in length and the user will guess until they get it right, getting a higher score for fewer guesses. Each guess must be a string of characters. For each character in the guess, it will be coloured one of three colours. If that character matches the password character in the same position, the colour is green. If the character does not match, but that character is in the password somewhere else, the colour is yellow. Otherwise it is gray.
Ingfríður is of course very good at her own game, so she will always guess a password that could be the hidden password. That is to say her guess will always match the previous clues. Furthermore she knows her program never generates passwords with repeated characters, since that's insecure, and will incorporate this knowledge into her guesses.
You now receive some screenshots from her testing progress, but they got so terribly compressed you can only make out the colours and not the text itself. Furthermore it seems that she didn't manage to make any progress at all. She didn't get a single green square in the entire game and never found any more characters than she did in her very first guess, and quit out of frustration. So the number of yellow squares is the same on each row. Given this info, can you reconstruct a sequence of guesses she could have made? Or is it impossible and her program must be wrong? You may assume that Ingfríður never makes any mistake when playing, only when programming.
입력
The first line of the input contains two positive integers and (). is the number of characters in the password and is the number of guesses in the screenshot. Next there are lines, each with characters, the -th of which gives the colours of the -th guess. G denotes gray and Y denotes yellow. The number of Ys is constant across all lines. The characters are given without spaces between them. Finally there is a single line with a single positive integer (), giving the number of valid characters for the passwords.
출력
If there is no way to achieve the given colours print Bugged!. Otherwise print lines with numbers each, separated by spaces. The first lines should give the colouring in the input if the number denotes the -th character in the alphabet. The final and -st line should give a secret word that could have resulted in this sequence of guesses being valid. If there are multiple possible solutions any one of them will be accepted.
예제
예제 1
3 4 GGYY YGGY GYYG 26
3 4 2 1 1 5 6 2 7 2 1 8 2 1 9 10
예제 2
4 5 GYGGY YGYGG GGYYG GYGGY 16
Bugged!