Թաքցված խնդիր
|Այս խնդիրը թաքցված է խմբագրական խրհրդի անդամի կողմից քանի որ կամ այն ոչ ճիշտ լեզվով է գրված,|կամ թեստային տվյալներն են սխալ, կամ խնդրի ձևակերպումը պարզ չէ։|

ACM_0046 - FRUSTRATED QUEUE

   The toilet in Freddy’s garden is broken, so his only chance are public toilets nearby. One day, there is a long queue of people in front of the toilets. Freddy is in a big need and so he desperately wants the queue to be served as quick as possible.

   To use the toilets, you need to pay 5 crowns. Half of the people in the queue have a 5-crown coin and the other half only have a 10-crown coin. Initially, the toilet operator has no coins, thus, the people in the queue have to reorganize so that whenever someone wants to pay with a 10-crown coin, the operator has at least one 5-crown coin available from previous customers.

   The issue is that some of the people in the queue are unwilling to give up their spot. Determine in how many ways can the people willing to change their position rearrange themselves in the queue so that the operator always has change available. The positions of those unwilling cannot change (they cannot be moved to a later but also to an earlier spot in the rearranged queue). Furthermore, among those willing to change the position, the relative order of those with the same coin must be preserved.

Input

   The input contains several test cases. Each test case consists of one line containing a non-empty string of parentheses and dots of length n ≤ 1 000. A dot indicates a person willing to change their position in the queue, an opening parenthesis indicates a person unwilling to change the position who has a 5-crown coin, and a closing parenthesis indicates a person unwilling to change the position who has a 10-crown coin.

   You may assume that n is even and that the string contains at most n/2 opening parentheses and at most n/2 closing ones.

Output

   For each test case, compute the number of ways the queue can be rearranged so that the conditions described in the statement of the problem are satisfied. Since this number may be too large, you are only required to print a single line containing one integer equal to the last 6 digits (in the decimal representation) of the number.

Examples

stdin

stdout

1

....

.(..

)...

.....)......................

2

1

0

68484


Ավելացրեց.Հրանտ Հովհաննիսյան
Ամսաթիվ.2013-12-27
Ժամանակի սահմանափակումը.1s
Ծրագրի տեքստի սահմանափակումը.50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Լեզուներ.Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE
Աղբյուրը.CTU Open 2013.F

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.