Limits 4s, 1.0 GB

There is a monster called lazyM in Rihamland who is the leader of this land. But another betrayer monster Arnab wants to kill lazyM. It is not easy to kill lazyM. He has n weak points and anyone can attack ith weak point at some particular time, but cannot attack more than one point at a time. To kill lazyM, Arnab needs to attack all the weak point of lazyM.
You will have the information of when lazyM’s ith weak point will appear and you need to find if Arnab can kill lazyM or not.

Input

Input starts with an integer T(1<=T<=10), denoting the number of test cases. 1st line of each case contains an integer n (1 ≤ n ≤ 8) donating the number of weak points of lazyM. Next n line contain Ai(1<= Ai <= 10^5) donating how many time ith (1 <= i <= n) week point will visible and followed by Ai positive integer donating visibility time (1 <= visibility time <= 10^5) of ith weak point.

Output

For each case of input, if Arnab can kill lazyM than print what would be the minimum time needed by Arnab to kill lazyM otherwise print “Arnab is weak”.

Sample

InputOutput
1
2
2 20 96
2 20 96
96

Submit

Login to submit.

Statistics

100% Solution Ratio
prodip_bsmrstuEarliest, Oct '19
nusuBotFastest, 0.1s
emrul_muLightest, 2.8 MB
emrul_muShortest, 2041B
Toph uses cookies. By continuing you agree to our Cookie Policy.