

Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 点
問題文
りんご海に 個の島が浮かんでおり、 社の業者がこれらの島を結ぶ船便を運行しています。便宜上、これらの島を島 と呼び、これらの業者を業者 , , と呼びます。
りんご海の海流は毎日大きく変わります。業者 は、その日の海の状況に応じて、島 から への便または島 から への便のどちらか一方のみを運行します。どちらの方向の便が運行されるかは、それぞれの業者について独立に、等確率で決定されるものとします。
いま、島 に高橋くんが、島 に低橋くんがいます。 社の業者による船便を用いて、高橋くんと低橋くんがその日のうちに同じ島に移動することができる確率を とします。ただし、船の所要時間などは無視します。このとき、 は整数となります。 を で割ったあまりを求めてください。
制約
- 組 はすべて異なる。
入力
入力は以下の形式で標準入力から与えられる。
出力
値 を で割ったあまりを出力せよ。
入力例 1Copy
4 3 1 3 2 3 3 4
出力例 1Copy
6

上図に示した 通りの状況が等確率で発生し、そのうち高橋くんと低橋くんが同じ島で出会える状況は 通りです。したがって、 となります。
入力例 2Copy
5 5 1 3 2 4 3 4 3 5 4 5
出力例 2Copy
18
入力例 3Copy
6 6 1 2 2 3 3 4 4 5 5 6 1 6
出力例 3Copy
64
Score : points
Problem Statement
There are islands floating in Ringo Sea, and travel agents operate ships between these islands. For convenience, we will call these islands Island and call these agents Agent .
The sea currents in Ringo Sea change significantly each day. Depending on the state of the sea on the day, Agent operates ships from Island to , or Island to , but not both at the same time. Assume that the direction of the ships of each agent is independently selected with equal probability.
Now, Takahashi is on Island , and Hikuhashi is on Island . Let be the probability that Takahashi and Hikuhashi can travel to the same island in the day by ships operated by the agents, ignoring the factors such as the travel time for ships. Then, is an integer. Find modulo .
Constraints
- All pairs are distinct.
Input
Input is given from Standard Input in the following format:
Output
Print the value modulo .
Sample Input 1Copy
4 3 1 3 2 3 3 4
Sample Output 1Copy
6

The scenarios shown above occur with equal probability, and Takahashi and Hikuhashi can meet on the same island in of them. Thus, and .
Sample Input 2Copy
5 5 1 3 2 4 3 4 3 5 4 5
Sample Output 2Copy
18
Sample Input 3Copy
6 6 1 2 2 3 3 4 4 5 5 6 1 6
Sample Output 3Copy
64