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
       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.
       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.
       For each case output the anwser mod 100000009 in a line.
Sample Input
Sample Output
The 7th(2012) ACM Programming Contest of HUST Problem Setter: Shuo Hu