#P9738. [COCI 2022/2023 #2] Prijateljice

[COCI 2022/2023 #2] Prijateljice

Problem Description

Leona and Zoe have some words. They plan to play a game with these words:

In each round, the two players take turns saying a word. The word must satisfy the following requirements:

It is lexicographically greater than the previous word, and its first letter must be the same as the first letter of the previous word, or exactly the next letter in the alphabet after the first letter of the previous word.

Leona speaks first, and he will choose the lexicographically smallest word to say. When it is someone’s turn and they cannot say a word, they lose.

While playing this game, both players use optimal strategies, that is, they always choose the lexicographically smallest word among all valid choices.

Now they want to know who will win.

Input Format

The first line contains two integers nn and mm (1n,m1051 \le n,m \le 10^5).

The next nn lines each contain a string, representing the words owned by Leona.

The next mm lines each contain a string, representing the words owned by Zoe.

All input words are lowercase letters and are pairwise distinct. Their total length does not exceed 10610^6. They are given in lexicographical order.

Output Format

Output one line containing a string, either Leona\texttt{Leona} or Zoe\texttt{Zoe}, indicating the winner.

2 1
avokado
dabar
brazil
Zoe
3 3
ananas
atlas
banana
albatros
cikla
nogomet

Leona
2 2
hrvatska
zastava
bijeli
galeb
Leona

Hint

Subtask\text{Subtask} Score Special Property
11 2020 n,m100n,m\le100, each word has length at most 1010
22 3030 n,m1000n,m\le1000
33 6060 None

The full score for this problem is 110110 points.

Translated by ChatGPT 5