Under construction

Still being built. Things may change

Number Baseball F

Time limit2sMemory limit512 MB

Summary
Guess a secret N-digit number with distinct digits by asking strike/ball queries, for up to 5040 games.
Level

Medium5 of 10

Topics
Brute force, Implementation, Combinatorics
Solved
No attempts yet

Problem

Play a game of number baseball against the grader.

Number baseball is a game where you guess an N-digit number A chosen by the grader. A consists of N distinct digits from 0 to 9, and it may start with 0. To guess A, you must ask the grader questions.

When you ask the grader about a number B, it tells you the number of strikes and balls. A strike is a digit that matches in both value and position, and a ball is a digit that matches in value but not in position.

Ask the grader questions and figure out what A is.

Input

The Sample Grader reads the following information from Standard Input.

The first line gives T and N. The next T lines give the numbers A chosen by the grader, one per line.

Output

The Sample Grader writes the following information to Standard Output.

If all the numbers chosen by the grader across the T games are guessed correctly, output "AC"; otherwise, output "WA".

Constraints

  • 1 ≤ T ≤ 5,040
  • 3 ≤ N ≤ 4

Examples1

  1. Example 1

    Input
    2 4
    0123
    3921
    
    Expected output
    AC