Hide

Problem J
Clash Royale

/problems/clashroyale/file/statement/en/img-0001.jpg
Fighting Image

In a Clash Royale Classic Challenge, players compete to achieve $12$ wins before accumulating $3$ losses. If a player has $3$ losses, the player’s score (including wins and losses) is reset, and they start again from $0$ wins.

You are given a stream of game results for multiple players, where each stream consists of characters ’W’ representing a win in a match, and ’L’ representing a loss.

Your task is to determine which player completes the classic challenge in the fewest number of matches. If multiple players reach $12$ wins in the same number of matches, the player appearing first in the input order is considered the winner. If none of the players completes the challenge, output “INCOMPLETE”.

Input

The first line contains an integer $N$ ($1 \le N \le 1\, 000$) which is the number of players. Following this, it will contain $N$ lines which contain a string with only the characters ’W’ and ’L’. Each string has a length of at least $1$ and at most $100$.

Output

Print the index of the player who completes the Classic Challenge in the fewest matches. If no player reaches $12$ wins before a reset, output “INCOMPLETE".

Sample Input 1 Sample Output 1
3
WWWWWWWWWWWW
LLLLWWWWWWWLLLL
WWWLLLWWWWWWWWWWWWWW
1
Sample Input 2 Sample Output 2
1
WWWW
INCOMPLETE

Please log in to submit a solution to this problem

Log in