CF38F.Smart Boy

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Once Petya and Vasya invented a new game and called it "Smart Boy". They located a certain set of words — the dictionary — for the game. It is admissible for the dictionary to contain similar words.

The rules of the game are as follows: first the first player chooses any letter (a word as long as 11 ) from any word from the dictionary and writes it down on a piece of paper. The second player adds some other letter to this one's initial or final position, thus making a word as long as 22 , then it's the first player's turn again, he adds a letter in the beginning or in the end thus making a word as long as 33 and so on. But the player mustn't break one condition: the newly created word must be a substring of a word from a dictionary. The player who can't add a letter to the current word without breaking the condition loses.

Also if by the end of a turn a certain string ss is written on paper, then the player, whose turn it just has been, gets a number of points according to the formula:

where

  • is a sequence number of symbol cc in Latin alphabet, numbered starting from 11 . For example, , and .
  • is the number of words from the dictionary where the line ss occurs as a substring at least once.

Your task is to learn who will win the game and what the final score will be. Every player plays optimally and most of all tries to win, then — to maximize the number of his points, then — to minimize the number of the points of the opponent.

输入格式

The first input line contains an integer nn which is the number of words in the located dictionary (1<=n<=30)(1<=n<=30) . The nn lines contain the words from the dictionary — one word is written on one line. Those lines are nonempty, consisting of Latin lower-case characters no longer than 3030 characters. Equal words can be in the list of words.

输出格式

On the first output line print a line "First" or "Second" which means who will win the game. On the second line output the number of points of the first player and the number of points of the second player after the game ends. Separate the numbers by a single space.

输入输出样例

  • 输入#1

    2
    aba
    abac
    

    输出#1

    Second
    29 35
    
  • 输入#2

    3
    artem
    nik
    max
    

    输出#2

    First
    2403 1882
    
首页