Poker Face


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C++, Java, Python

Since you're a wannabe HFT employee, the first game you decide to play at the casino is Poker. You sit down at the first table you see and study the person across from you. You wonder if they have any tells...

A tell is something a player subconsciously does that might reveal the quality of their hand. For your purposes, let's define a tell as an action that the player does only when they win, and never when they lose.

Over the course of three games, you keep track of your opponent's actions and whether they won or lost:

  • Game 1: They won. Actions: smile, yawn, blink
  • Game 2: They lost. Actions: blink
  • Game 3: They won. Actions: smile, blink

Based on this, you conclude that the only action they do only when they win is smile. So smile is a tell.

Given your opponent's games and actions, what tells do they have?

Input

The first line consists of an integer n (1 \leq n \leq 1000), the number of games you play against your opponent.

The next n lines contain c, k, and A_1, A_2, ..., A_k, where:

  • c is W if your opponent won and L if the player lost;
  • k (1 \leq k \leq 100) is the number of actions your opponent did during that game;
  • A_i (1 \leq A_i.\text{length} \leq 10) is a string representing the ith action your opponent did.

Output

Output all of your opponent's tells, in alphabetical order. If they have no tells, output -1.

Example

Input 1
3
W 3 Smile Yawn Blink
L 1 Blink
W 2 Smile Blink
Output 1
Smile

This is the above example.

Input 2
4
W 4 Squint Smile Laugh Talk
W 2 Laugh Talk
L 1 Smile
W 3 Laugh Talk Squint
Output 2
Laugh
Talk

Your opponent does 2 things only when they win — talk and laugh.

Input 3
2
W 1 Smile
W 1 Frown
Output 3
-1

Your opponent doesn't have any actions they do only when they win, so they have no tells.

Input 4
3
L 1 Cry
L 1 Cry
L 1 Cry
Output 4
-1

Your opponent never wins (sad) so there's no actions they only do when they win.


Comments

There are no comments at the moment.