Sofia is organizing her collection of books. She has $$$N$$$ stacks of books, each one should contain only books of the same genre. For this reason, Sofia has encoded the genres of her books with numbers from $$$1$$$ to $$$N$$$, such that books of genre $$$i$$$ should be in stack $$$i$$$.
To make her task more fun, Sofia will try to organize her collection by making only the following type of move: taking the book from the top of one stack and placing it on the top of another stack.
Tell her if it is possible to organize her collection using only this type of move. She can make as many moves as necessary.
The first line contains the integer $$$N$$$ $$$(1 \le N \le 100)$$$, the number of stacks (and genres of books). The following $$$N$$$ lines contain the description of the $$$N$$$ stacks. Each line starts with a non-negative integer $$$K_i$$$ equal to the number of books in that stack, followed by $$$K_i$$$ integers $$$L_j$$$ $$$(1 \le L_j \le N)$$$ equal to the genre of each of those books. The books are described in the list such that the last one is on top.
It is guaranteed that $$$\sum_{i=1}^{N} K_i \le 300$$$. Note that there may be no books of some of the $$$N$$$ genres.
Print only one line with a character, 'S' if it is possible to organize the books according to the statement or 'N' if it is not possible.
3 3 3 2 1 0 0
S
2 2 1 2 2 1 2
N
Explanation of example 1:
She can move the book of type $$$1$$$ to stack $$$2$$$, then move the book of type $$$2$$$ to stack $$$2$$$, and then it is possible to move the book of type $$$3$$$ to stack $$$3$$$, thus the book of type $$$3$$$ will already be in the right place. After that, she can move the book of type $$$2$$$ to stack $$$3$$$, then the book of type $$$1$$$ to stack $$$1$$$. Finally, move the book of type $$$2$$$ to stack $$$2$$$ and thus all the books will be in the correct stack.