아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Prijateljice

시간 제한1초메모리 제한1024 MB

요약
두 사람이 번갈아 자신의 단어 더미에서 직전 단어보다 사전순으로 크고 첫 글자가 같거나 바로 다음 글자인 단어를 말하며, 레오나가 자신의 가장 작은 단어로 시작할 때 최선의 플레이에서 이기는 사람을 구한다.
난이도

보통10점 중 7점

유형
게임 이론, 그리디, 투 포인터, 구현
정답자
아직 제출이 없습니다

문제

One summer night in Krk, Leona and Zoe went for a walk. On their winding path, they found a pile of words! Excited by that, they quickly started collecting them: Leona collected n words, and Zoe m words. After admiring them for a while, they decided to play the following game:

In one move a player says a word from her pile. The player chooses the word in such a way that the following conditions are met: the word is lexicographically greater than the previous word, and it begins with the same letter as the previous word or with the first letter of the English alphabet after it. If a player can’t make a move, she loses.

They alternate turns, and Leona plays first by saying her lexicographically smallest word. If Leona and Zoe play optimally, determine who wins.

Note: The word A is lexicographically smaller than the word B if the word A is a prefix of the word B or if in the first position in which the words A and B differ the letter in A at that position comes before the letter in B at that position.

입력

The first line contains integers n and m (1 ≤ n, m ≤ 105), the number of Leona’s words, and the number of Zoe’s words.

The following n lines contain Leona’s words.

The following m lines contain Zoe’s words.

Words from the input contain only lowercase letters of the English alphabet, all words are mutually distinct, their total length is at most 106, and Leona’s and Zoe’s words are lexicographically sorted.

출력

Output Leona or Zoe, the name of the winner.

힌트

Clarification of the first example: Leona starts with the word avokado, then Zoe continues with her only word brazil. Leona can’t make any move so she loses.

예제3

  1. 예제 1

    입력
    2 1
    avokado
    dabar
    brazil
    
    예상 출력
    Zoe
    
  2. 예제 2

    입력
    3 3
    ananas
    atlas
    banana
    albatros
    cikla
    nogomet
    
    예상 출력
    Leona
    
  3. 예제 3

    입력
    2 2
    hrvatska
    zastava
    bijeli
    galeb
    
    예상 출력
    Leona