CF185D Visit of the Great

Description

The Great Mushroom King descended to the dwarves, but not everyone managed to see him. Only the few chosen ones could see the King. We know that only $ LCM(k^{2^l}+1,k^{2^{l+1}}+1,...,k^{2^r}+1) $ dwarves can see the Great Mushroom King. Numbers $ k $ , $ l $ , $ r $ are chosen by the Great Mushroom King himself in some complicated manner which is unclear to common dwarves. The dwarven historians decided to document all visits of the Great Mushroom King. For each visit the dwarven historians know three integers $ k_{i} $ , $ l_{i} $ , $ r_{i} $ , chosen by the Great Mushroom King for this visit. They also know a prime number $ p_{i} $ . Help them to count the remainder of dividing the number of dwarves who can see the King, by number $ p_{i} $ , for each visit.

Input Format

N/A

Output Format

N/A

Explanation/Hint

We consider that $ LCM(a_{1},a_{2},...,a_{n}) $ represents the least common multiple of numbers $ a_{1} $ , $ a_{2} $ , $ ... $ , $ a_{n} $ . We consider that $ x^{0}=1 $ , for any $ x $ .