Po & Dumpling

Author: Abu Rayhan Ahmad

Problem setter: Abu Obaida Opu. Software Engineer.

Structured Data Systems Ltd (SDSL)

Po loves to eat dumpling. He would keep eating endlessly if he could. Today when Po went out to take a walk in the road, he immediately remembered, ohh today is dumpling festival!!! Unfortunately before going out Po ate too much dumpling and he is full. Now Po is thinking, “I want to take all dumplings with me!”.But to carry dumplings, he need bags. Immediately Po noticed, there are some shops selling bags too! For simplicity of problem, consider the road as a straight line, and Po can only go on one direction (Either left or right). His journey ends when he reaches end of the road. Po wants to take as much dumpling possible with him. But he just can’t do math when his brain only wants to eat. So he called you to tell which way he should go, so that he can collect maximum number of dumpling and also tell him how many dumpling he will collect. One empty Bag can contain 10 dumpling and Po can only take a dumpling if he has bag with him and that bag isn’t filled with dumplings.

 

You are given an array of length N containing characters P, D, B and E. P is the position where Po is standing. D means there is one Dumpling, B means there is an empty Bag and E means that position is empty. Find out which way Po should go (“Left” or “Right”) and how many Dumpling he will collect going that direction. If Po can collect maximum amount of dumpling going either way, he will always go "Right", as he thinks that is the right thing to do.

Input Format

Input starts with an integer T (≤ 1000), denoting the number of test cases.

Each test case will have two lines. First line will have a number N(<=10^3) and the second line will have an array S of length N. You can assume that there will be only one P in a test case.

Output Format

For each case print the case number, a string- “Left” or “Right” indicating which way Po should go and an integer X indicating the maximum number of dumpling he will collect going on that direction.

Samples

Input
2 5 EDPBD 11 DDEDBDPEBDD
Output
Case 1: Right 1 Case 2: Left 3
Limits
Language Time Memory
GNU C 11 1s 512MB
GNU C++ 14 1s 512MB
GNU C++ 11 1s 512MB
PHP 7 1s 1024MB
Java (OpenJDK 8) 1s 4096MB
Statistics
Login To Submit