Never Ending Rivalry

0

0 votes
Problem

The rivalry of Lionel Messi and Cristiano Ronaldo has gone to a different level. So to predict the winner of the rivalry they are given a problem.

Lionel Messi has been provided the goals (imaginary) scored by Ronaldo as String 'A' and Ronaldo has been provided the goals scored (imaginary) by Messi as String 'B' ( both the strings are of equal length) and they have to divide the string into two non-empty parts such that each of them contains a positive integer without leading zeros(Subpart of the string cannot start with 0 i.e String 345 is valid but strings like 0345 and 00345 are not valid). After that they will do the sum of those two subparts of both strings.

And they both want the resulting integer to be as small as possible to win the rivalry. So, after minimizing the integer the one who has the maximum number of goals is the winner i.e. the one who has got minimum integer from the string is the winner. So, you have to predict the winner and print "Messi" if Lionel Messi is the winner or print "Ronaldo" if Cristiano Ronaldo is the winner else print "Draw".

INPUT FORMAT:

  • The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
  • The first line of each test case contains a single integer N.
  • Second line of each test case contains string A of length N.
  • Third line of each test case contains string B of length N.

OUTPUT FORMAT:

  • Print T lines in which ith line contains the winner (Messi or Ronaldo) of the ith test case.

CONSTRAINTS:

1 <= T <= 10

1 <= N <= 105

The sum of N over all test cases does not exceed 105

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

The best way in which Lionel Messi can divide the string '310001' (Ronaldo's Goals count)  into two parts to get the minimum resulting string is ( 3 and 10001 , resulting string is 3 + 10001 = 10004 ) . Similarly Ronaldo will divide '120000' (Messi's Goals count )  in ( 1 + 20000 = 20001). So , 20001 > 10004, so Messi still has more goals. So, "Messi" is the Winner.

Editor Image

?