1997 Programming Contest

Results

Thirteen teams from various schools in Idaho participated in the second High School programming contest. There were a total of 31 students and the teams were from the following schools:

The first place team was from Centennial High School. They finished all three problems correctly (and ahead of other teams). The team members were David Hay, Scott Stringham, and Trevor Schultz.

The second place team was from Boise High School. They finished problem 1 correctly (and ahead of rest of the teams). In addition, they came really close to finishing the other two problems. The team members were Lizzi Barchas, Cap Petschulat, and Adam Cox.

Additionally, five more teams were able to complete the program for problem one correctly.

The Problems

Here are the problems used in the competition.






Problem 1: Weighting Strings

Consider the following procedure for finding the weight of a string. Your program should compute the weight of the given string.

Input.

The input consists of a string that starts in column 1 and does not exceed column 10.

Output.

Print the weight of the string.

Examples.

Input        Output 
       
az          weight = 27 
aaZZa       weight = 85 
aaaaaaaaaa  weight = 1023
23%234      weight = 0

Problem 2: Word Construction

A doublet is written on two cards, for example:

COMPUTER COMPUTER

A new word is formed by joining a substring from the first card to a substring from the second card.

PUT TER

Here the word ``PUTTER" is formed.

You will be given one doublet, followed by a word, and you must print this word as output if it can be formed in the above way as a pair of substrings. For this problem, valid substrings must have at least two letters.

Input

The input is the doublet, followed by N, (1 <= N <= 10) the number of words in the list, followed by the N words, one per line. All words (including the doublet) will be in lowercase letters, and will have between 2 and 32 letters.

Output

The output will be any words that can be formed by taking two substrings from the doublet. Each word should appear on a line on its own.

Examples.

Input

computer
3
onion
cute
putter
Output
putter
Input
paw
3
apaw
papa
wap
Output
papa

Problem 3: Partial Primes

An integer substring of an integer is formed by consecutive digits of the original integer. For example, the number 6158 contains the substrings 6, 1, 5, 8, 61, 15, 58, 615, 158, and 6158. You must find the largest substring of an integer that is also a prime. Remember that the smallest prime number is 2.

Input.

The input will be an integer N, (0 <= N <= 1,000,000,000).

Output.

The output will be the largest prime substring of N. If no substring is a prime, then your program should print ``No Primes".

Examples

Input        Output

2319         31
6804         No Primes
73930139     73930139