Abhimanyu has a complete binary tree of level L, called Crazy Tree. Levels are numbered 1, 2, ..., L from top to bottom and root is at level 1. Abhimanyu numbers all the leaf nodes 1, 2, 3, ... from left to right. The value of the parent node is the product of values of its child node.
Below are level 2 (left) and level 3 (right) crazy trees
Abhimanyu defines a magical function S:
Abhimanyu wants to find the value of S(N, X, Y) % M for given values of N, X, Y, where M = 1299709.
Input
First line of input contains two space separated integers L and Q, where L is number of levels in the crazy tree and Q is total number of queries. Each of the next Q lines contains three space separated integers N, X and Y.
Output
Output the value of S(N, X, Y) % M in single line for each test case.
Constraints
As Tree has 3 levels you can refer to right image above.
Now for query 2 1 2 At level 2, Value of node 1 = 2 At level 2, value of node 2 = 12
So, S(2, 1, 2) = 2 + 12 = 14