# Problem F

Cyclical Periods

Given a sequence of strings of lowercase letters (arbitrary ordering of letters in each string) and their positions on the number line, your task is to determine which letter represents the cycle with the longest period. The number line will start at 1 and will not be longer than $65{,}536$. Any letter that appears will appear at least twice, and it will appear on the entire number line at locations consistent with its offset and period.

## Input

The first line contains an integer $N$ ($2 \leq N \leq 65{,}536$), representing the number of strings on the number line. Each subsequent line describes a position on the number line that has at least one letter associated with it. Each description line begins with a positive integer $P$ ($1 \leq P \leq 65{,}536$) representing the position on the number line followed by a space, and then the string of lowercase letters associated with this position. No letters will be repeated within a string, and the positions are strictly increasing from one line to the next.

## Output

Print the single letter that represents the longest cycle length. In case of a tie, use the cycle that appears at the earliest position. If there is still a tie, use the letter that appears first in the string when the cycle is first discovered.

Sample Input 1 | Sample Output 1 |
---|---|

18 2 b 3 a 4 d 5 c 6 ab 9 a 10 b 12 ac 14 b 15 ad 18 ab 19 c 21 a 22 b 24 a 26 bcd 27 a 30 ab |
d |

Sample Input 2 | Sample Output 2 |
---|---|

4 1 pz 2 d 4 zp 5 d |
z |