The Ranger’s Seasonal Guess

A park ranger sees one animal per day. Some animals show up more often in certain seasons, so yesterday’s sightings matter more than those from a long time ago.

Today, the ranger asks you to predict which animal they’ll see today, but you should only look at the last X days of sightings.

seasonal-guess.jpg

The first line of the input contains two integers n and x, where n is the total number of days recorded, and x is the number of most recent days you should consider (1 ≤ x ≤ n).

The second line contains n space-separated animal names (the names don’t contain spaces), listed from oldest to newest.

The program should print the name of the animal that appears most frequently within the last x days. In case there are several equally likely candidates, the program should print the alphabetically smallest one.

Input

Output

6 3
deer fox deer rabbit fox fox

fox

8 5
bear wolf deer wolf bear wolf lynx bear

bear

5 5
hawk eagle hawk eagle lynx

eagle

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue