Purple Rain

Given a string of R and B characters, find the contiguous block maximizing |r - b|, breaking ties by westernmost start then westernmost end.

Medium5ArrayGreedyPrefix sumImplementationInterviewNo attempts yetTime limit1sMemory limit512 MB

Problem

Purple rain falls on Linearland, a magic kingdom shaped like a straight, thin peninsula.

Professor Nelson Rogers looked at the rain closely and found that the purple rain is really a mix of red raindrops and blue raindrops.

He recorded the position and the color of the raindrops at many points along the peninsula. Reading the data, Professor Rogers wants to know which part of Linearland had the least purple rain.

He models the question like this. Divide the peninsula into nn sections and number them 11 to nn from west to east. Write R for a section whose rain was mostly red and B for a section whose rain was mostly blue, which gives a string of length nn. Then find a block of consecutive sections in which the difference between the number of R and the number of B is largest. If a block holds rr letters R and bb letters B, the value to maximize is rb|r - b|.

Input

The first line contains a string of nn characters (1n1051 \le n \le 10^5). The ii-th character is the color of the rain in section ii.

The string consists of the uppercase ASCII letters R and B only.

Output

Print two space separated integers on a single line: the starting section and the ending section of the part of Linearland that had the least purple rain. The two numbers describe an inclusive range, so both sections belong to the range.

If several answers are possible, print the one with the westernmost starting section. If several answers share that starting section, print the one with the westernmost ending section.