CF2064B.Variety is Discouraged

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

Variety is Discouraged

Define the score of an arbitrary array bb to be the length of bb minus the number of distinct elements in bb. For example:

  • The score of [1,2,2,4][1, 2, 2, 4] is 11, as it has length 44 and only 33 distinct elements (11, 22, 44).
  • The score of [1,1,1][1, 1, 1] is 22, as it has length 33 and only 11 distinct element (11).
  • The empty array has a score of 00.

You have an array aa. You need to remove some non-empty contiguous subarray from aa at most once.

More formally, you can do the following at most once:

  • pick two integers ll, rr where 1lrn1 \le l \le r \le n, and
  • delete the contiguous subarray [al,,ar][a_l,\ldots,a_r] from aa (that is, replace aa with [a1,,al1,ar+1,,an][a_1,\ldots,a_{l - 1},a_{r + 1},\ldots,a_n]).

Output an operation such that the score of aa is maximum; if there are multiple answers, output one that minimises the final length of aa after the operation. If there are still multiple answers, you may output any of them.

Input

The first line contains an integer tt (1t1041 \le t \le 10^4) — the number of testcases.

The first line of each testcase contains an integer nn (1n21051 \le n \le 2 \cdot 10^5) — the length of the array aa.

The second line of each testcase contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (1ain1 \le a_i \le n).

The sum of nn across all testcases does not exceed 21052 \cdot 10^5.

Output

For each testcase, if you wish to not make a move, output 00.

Otherwise, output two integers ll and rr (1lrn1 \le l \le r \le n), representing the left and right bound of the removed subarray.

The removed subarray should be chosen such that the score is maximized, and over all such answers choose any of them that minimises the final length of the array.

Note

In the first testcase, we have two options:

  • do nothing: the score of [1][1] is 11=01-1=0.
  • remove the subarray with l=1l=1, r=1r=1: we remove the only element, and we get an empty array with score 00.

Therefore, the maximum score possible is 00. However, since we need to additionally minimise the final length of the array, we must output the second option with l=r=1l=r=1. Note that the first option of doing nothing is incorrect, since it has a longer final length.

In the second testcase, no subarray is selected, so after which aa is still [1,1,1,1,1][1, 1, 1, 1, 1]. This has length 55 and 11 distinct element, so it has a score of 51=45 - 1 = 4. This can be proven to be a shortest array which maximises the score.

In the third testcase, the subarray selected is [2,1,3,2][2, \color{red}1, \color{red}3, 2], after which aa becomes [2,2][2, 2]. This has length 22 and 11 distinct element, so it has a score of 21=12 - 1 = 1. This can be proven to be a shortest array which maximises the score.

Samples

3
1
1
5
1 1 1 1 1
4
2 1 3 2
1 1
0
2 3

在线编程 IDE

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