CF2144A.Cut the Array

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Cut the Array

You are given an array of nn non-negative integers [a1,a2,,an][a_1, a_2, \dots, a_n].

Your task is to cut it into three non-empty parts: a prefix, a middle part, and a suffix. Formally, you need to choose two integers ll and rr such that 1l<r<n1 \le l \lt r \lt n, and obtain three parts:

  • the prefix up the element at index ll inclusive (i.e., [a1,a2,,al][a_1, a_2, \dots, a_l]);
  • the central part from the element at index l+1l+1 to the element at index rr inclusive (i.e., [al+1,al+2,,ar][a_{l+1}, a_{l+2}, \dots, a_r]);
  • the suffix from the element at index r+1r+1 to nn inclusive (i.e., [ar+1,ar+2,,an][a_{r+1}, a_{r+2}, \dots, a_n]).

Let s1,s2,s3s_1, s_2, s_3 be the remainders of the sums of these parts modulo 33. In other words:

  • s_1 = ( um\limits_{i=1}^{l} a_i) \bmod 3;
  • s_2 = ( um\limits_{i=l+1}^{r} a_i) \bmod 3;
  • s_3 = ( um\limits_{i=r+1}^{n} a_i) \bmod 3.

Your task is to find such boundaries ll and rr that either all numbers s1,s2,s3s_1, s_2, s_3 are different, or all numbers s1,s2,s3s_1, s_2, s_3 are the same.

Input

The first line contains a single integer tt (1t10001 \le t \le 1000) — the number of test cases.

Each test case consists of two lines:

  • the first line contains a single integer nn (3n403 \le n \le 40);
  • the second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (0ai400 \le a_i \le 40).

Output

For each test case, if a suitable pair of integers ll and rr (1l<r<n1 \le l \lt r \lt n) exists, output these two integers (if there are multiple suitable pairs, you can output any of them). Otherwise, output two integers equal to 00.

Note

Consider the examples from the statement:

  • in the first example, the array is cut into parts [1,2,3][1, 2, 3], [4,5][4, 5], [6][6]; s1=s2=s3=0s_1 = s_2 = s_3 = 0;
  • in the second example, there is no suitable cut;
  • in the third example, the array is cut into parts [2][2], [1][1], [0][0]; s1=2s_1 = 2, s2=1s_2 = 1, s3=0s_3 = 0;
  • in the fourth example, the array is cut into parts [7,2][7, 2], [6,2][6, 2], [4][4]; s1=0s_1 = 0, s2=2s_2 = 2, s3=1s_3 = 1.

Samples

4
6
1 2 3 4 5 6
4
1 3 3 7
3
2 1 0
5
7 2 6 2 4
3 5
0 0
1 2
2 4

在线编程 IDE

建议全屏模式获得最佳体验