407340: GYM102767 F Subarray with Maximum Product?
Description
Given a sequence of integers $$$a_1 , a_2 , \ldots , a_n$$$ and a prime number $$$x$$$.
We have a function which takes $$$length$$$ as a parameter and return the maximum possible value of $$$ (a_i\times a_{i+1}\times \cdots \times a_{i+length-1})\pmod x$$$ , where $$$1 \le i \le (n-length+1) $$$.
For example – $$$a = [2,3,4,2] , x = 5 $$$.
For $$$length = 1$$$ , function return $$$\max(2,3,4,2) = 4$$$.
For $$$length = 2$$$ , function return $$$\max((2\times 3)\pmod 5 , (3\times 4)\pmod 5 , (4\times 2)\pmod 5) = \max(1,2,3) = 3$$$.
For $$$length = 3$$$ , function return $$$\max((2\times 3\times 4)\pmod 5 , (3\times 4\times 2)\pmod 5) = \max(4,4) = 4$$$.
For $$$length = 4$$$ , function return $$$\max((2\times 3\times 4\times 2)\pmod 5) = \max(3) = 3$$$.
Your task is to find the smallest length for which this function return maximum possible value.
InputThe first line contains a single integer $$$t (1 \le t \le 10^5)$$$ — the number of test cases in the input. Then $$$t$$$ test cases follow.
Each query contains two lines. The first line contains two integer $$$n (1 \le n \le 10^5)$$$: the number of integers in the sequence and $$$x (2 \le x \le 97)$$$, and the second line contains $$$n$$$ integers $$$a_1, \ldots ,a_n (1\le a_i < x)$$$.
It is guaranteed that the total sum of $$$n$$$ is at most $$$10^5$$$ and $$$x$$$ be a prime number.
OutputPrint $$$t$$$ answers to the test cases. Each answer must be consisting of two integers — the maximum possible value of function and the smallest length for which function return maximum possible value.
ExampleInput5 4 5 2 3 4 2 4 3 1 1 1 1 3 7 2 3 6 3 7 5 5 5 3 11 5 6 7Output
4 1 1 1 6 1 6 3 9 2Note
In the first query — Explained in Problem Statement. For $$$length = 1$$$ and $$$3$$$, Function return maximum value i.e $$$4$$$. We have to return the minimum length i.e $$$1$$$.
In the fourth query —
For $$$length = 1$$$ , function return $$$\max(5,5,5) = 5$$$.
For $$$length = 2$$$ , function return $$$\max((5\times 5)\pmod 7 , (5\times 5)\pmod 7) = \max(4,4) = 4$$$.
For $$$length = 3$$$ , function return $$$\max((5\times 5\times 5)\pmod 7) = \max(6) = 6$$$.