The 7th(2012) ACM Programming Contest of HUST - Onsite Contest(Semilive)

From: 2012-12-16 12:10:00 To: 2012-12-16 17:10:00 Now: 2017-09-24 21:40:06 Status: Public

H - Little Sheep and a paper

Time Limit: 2s Memory Limit: 128MB

Submissions: 479 Solved: 140
Description
       One day, god Sheep gets an AK(all kill) in a contest, so he is very boring, then he just plays with a paper. The paper has two faces called A and B. Sheep finds the paper can be folded for infinity times, and now Sheep thinks the paper is interesting, so he tries to fold the paper in half for many times. He finds out he has four way to make the paper folded in half, there are listed below:
 
图片请见 PDF版题目。


At first, god Sheep keeps the face A of the paper faced to him,and he fold the paper for many times. In the end, Sheep opens up the paper, and keeps the face A faced to him again. Now the question is : How many creases on the face A of the paper are protruding? God sheep solves the question without 2 seconds. Can you?  You should make your anwser mod 100000009.
Input
       The first line of input contains a single positive integer N , which means the number of test cases. The following N lines gives N non-empty strings containing only characters in "UDLR", which is the sequences of the actions of the Sheep to fold paper. The length of the each string is a positive number less than 10^6.
Output
       For each case output the anwser mod 100000009 in a line.
Sample Input
4
L
LR
DLUR
ULULL
Sample Output
0
1
10
22
Hint
Source
The 7th(2012) ACM Programming Contest of HUST Problem Setter: Shuo Hu