The 2024 League of Legends World Championship culminated in an epic clash between two titans of professional League of Legends on November 2, 2024. Bilibili Gaming, after dominating the LPL with two domestic titles in 2024, undoubtedly carried the hopes of China's premier league that had endured three years without lifting the Summoner's Cup. In their way stood T1, who had qualified as LCK's fourth seed but proved their championship mettle through their tournament run. And there he was — Faker, the man revered as "the highest mountain and the longest river" — still standing at the center of LoL's greatest stage as if time itself had learned to bow before him. With four crowns already weighing heavy in his legacy, Faker somehow made the hunt for a fifth feel less like ambition and more like destiny. Now, beneath the towering dome of London's O2 Arena, the stakes were immense for both teams: BLG aimed to end the LPL's drought and cement their remarkable 2024 campaign, while T1 sought to defend their title and further establish their dynasty.
In an electrifying best-of-five series that pushed both teams to their limits, T1 emerged victorious over BLG with a hard-fought 3-2 triumph, clinching their fifth world championship. True to the tournament's official slogan "Make Them Believe", T1 mounted an incredible comeback from a 1-2 deficit, reaffirming once again why they remain a seemingly insurmountable obstacle for LPL teams in the international arena.
As we trace back through the journey of these two finalist teams, it all started in that fateful knockout stage, where eight teams competed in a single-elimination tournament: LNG Esports, Weibo Gaming, Hanwha Life Esports, Bilibili Gaming, Top Esports, T1, Gen.G, and FlyQuest. In an eight-team single-elimination tournament format, teams were seeded into the bracket based on their performance in the Swiss stage to face off in head-to-head matches where the loser is immediately eliminated. The tournament progresses through three rounds: Quarterfinals with eight teams, Semifinals with four teams, and the Finals with two teams, ultimately crowning a single champion.
Figure: Eight-Team Single-Elimination Tournament Bracket Although Worlds 2024 has irretrievably passed into history, we can still craft our own version of the story. For this problem, you will simulate a hypothetical knockout stage using the same eight-team single-elimination format. You will be given the names and the strength values of the eight teams in order from top to bottom of the Quarterfinals bracket (shown in the leftmost column in Figure), and both the names and the strength values are guaranteed to be pairwise different. When two teams compete, the team with the higher strength value always wins, while the losing team is eliminated. For two teams competing in the Finals, the team that wins is designated as the champion, while the other team is designated as the runner-up.
Your task is to find the champion team and the runner-up team in the hypothetical knockout stage.
The input contains eight lines, the $$$i$$$-th of which contains a string $$$S_i$$$ ($$$1 \leq |S_i| \leq 3$$$) and an integer $$$t_i$$$ ($$$1 \leq t_i \leq 100$$$), indicating the name and the strength value of the $$$i$$$-th team from top to bottom of the Quarterfinals bracket.
It is guaranteed that all team names contain only uppercase English letters or decimal digits, and both the names and the strength values are pairwise different.
Output "A beats B" (without quotes) in one line, where A is the name of the champion team and B is the name of the runner-up team.
LNG 55WBG 65HLE 70BLG 75TES 48T1 80GEN 60FLY 50
T1 beats BLG
LNG 55WBG 65HLE 70BLG 81TES 48T1 80GEN 60FLY 50
BLG beats T1
In the second sample case, since we intentionally increase BLG's strength value in the hypothetical knockout stage, please note that the outcome of the Finals, sadly, differs from the actual Worlds 2024.