SP3359 STACK - Stack

Description

Alan loves to construct a stack of building bricks. His stack consists of many cuboids with square base. All cuboids have the same height 1. Alan puts the consecutive cuboids one over another. Recently in math class, the concept of volume was introduced to Alan. Consequently, he wants to compute the volume of his stack now. The lengths of cuboids bases (from top to bottom) are constructed by Alan in the following way: - Length of edge of the first square is one. i.e. **a $ _{1} $** = 1. - Next, Alan fixes the length of the edge of the second square **a $ _{2} $** . - Next, Alan calculates the length **a $ _{n} $** (n > 2) by **2\*a $ _{2} $ \*a $ _{n-1} $ - a $ _{n-2} $** . Do not ask why he chose such a formula; let us just say that he is a really peculiar young fellow.

Input Format

The input contains several test cases. The first line contains the number t (t

Output Format

For each test case compute the volume of stack of **N** consecutive bricks constructed by Alan according to steps 1 to 3 and output its remainder modulo **m**.