407663: GYM102868 A Black
Description
You, the Black character, stroll into the Reactor room, ready to drum up the reactor machine for a long day of intergalactic travel. The start up mechanism requires you to diligently repeat a series of patterns on the reactor's button pad, each time copying the pattern of light flashes shown on a screen beside the pad. Conveniently, you happen to have picture perfect memory and so remember the location of every light flash you see. The only problem is, you get easily distracted and often miss button presses while you're looking away at something else.
Complete your important task! For each target pattern, given the light flashes that you see for several repeats of the pattern, determine whether or not you, with your perfect memory, can deduce the target pattern.
Note that the button pad contains 9 buttons, and you keep track of the button locations and corresponding light flashes according to the letters A through I. Importantly, also note that you have preconfigured the reactor pad to only generate target patterns without duplicate button presses, meaning there will be no repeated button presses or flashes within the target pattern.
InputThe first line of input contains an integer $$$T$$$ ($$$1 \leq T \leq 1000$$$), denoting the number of target patterns that you must enter into the reactor pad. Then for each target pattern, the first line contains two space-separated integers: $$$N$$$ ($$$1 \leq N \leq 9$$$) denoting the length of the target pattern and $$$R$$$ ($$$1 \leq R \leq 100$$$) denoting the total number of repeats of the target pattern you've witnessed. $$$R$$$ lines follow, each containing an integer $$$r_i$$$ ($$$1 \leq r_i \leq N$$$) followed by $$$r_i$$$ capital letters (A through I) denoting the locations of light flashes in the order that you saw them for that repeat of the target pattern. The data is guaranteed to be consistent with a valid target pattern.
OutputFor each target pattern, output "NOT ENOUGH INFO" if you are unable to deduce it, or output the target pattern on one line if you are in fact able to figure it out with full confidence, given what you've seen.
ExampleInput3 5 3 3 A C E 3 B D E 4 A B D E 1 1 1 C 5 3 4 D A B C 3 E B C 3 D E AOutput
NOT ENOUGH INFO C D E A B C