Diwali lightings

Given a pattern S repeated infinitely and a range [I, J], count how many bulbs in that range are blue.

Easy3MathPrefix sumImplementationStringInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

Diwali is the festival of lights. Pari loves lights, so she bought an infinite number of red and blue bulbs. She also likes regular arrangements, so she lays the bulbs out in one line by repeating a finite pattern SS forever.

For example, if SS is BBRB, the bulbs are placed in the order BBRBBBRBBBRB.... Here B means blue and R means red.

The bulbs are numbered with consecutive integers starting from 1. The arrangement above is numbered like this.

B  B  R  B  B  B  R  B  B  B  R  B...
1  2  3  4  5  6  7  8  9  10 11 12

Blue is Pari's favorite color. Count the blue bulbs from bulb II through bulb JJ, inclusive.

Input

The first line contains the number of test cases TT. The TT test cases follow.

The first line of each test case contains the pattern SS to repeat. The second line contains two integers II and JJ separated by a single space.

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting from 1 and yy is the number of blue bulbs from bulb II through bulb JJ, inclusive.

Constraints

  • 1T1001 \le T \le 100
  • 1S1001 \le |S| \le 100
  • Each character of SS is an uppercase B or an uppercase R.
  • 1IJ1061 \le I \le J \le 10^6

Notes

If SS is BR, every odd numbered bulb is blue and every even numbered bulb is red.