SP1459 AEROLITE - The Secret of an Aerolite

Description

A huge aerolite had fallen in Antarctica!!!Many disasters happened and lots of people lost their lives, homes or even everything.Blue Mary, the well-known scientist, is to work out the secret of this aerolite for further study. Blue Mary has found out that their are some numbers on this aerolite, 5 per line: ``` 1 1 1 1 6 0 0 6 3 57 8 0 11 3 2845 ``` With her genius, Blue Mary knows that the 5th number is the key to solve the problem, but in some lines the 5th numbers were destoryed and we cannot know what they are instantly. After some days, she finds out the way to calculate the 5th number finally, which is: - A Regular Expression(RE) is a string which only contains characters '{','\[','(',')','\]','}' and satisfies the rules below. - An empty string is an RE. - If there's no character '\[','\]','{','}' in RE A, then (A) is an RE. - If there's no character '{','}' in RE A, then \[A\] is an RE. - If A is an RE, {A} is an RE. - If both A and B are REs, AB is an RE.

Input Format

Input contains exactly 10 test cases.Each test case contains one line, which contains 4 numbers L1,L2,L3,D(0

Output Format

Ten lines, each contains a single integer denoted the 5th number.