Clone and Create

Easy
3
1
8.3% Acceptance

Dive into a unique challenge at Codedamn, where your logic and creativity will be put to the test. Imagine you have a sequence of integers, along with a fascinating operation at your disposal: "Copy-Paste." This operation allows you to select any continuous part of your sequence and replicate it at any spot within the sequence itself. For instance, starting with the sequence [1, 2, 3, 4, 5] and choosing to copy the subsection from the second to the fourth element, then pasting it after the third one, transforms your sequence to [1, 2, 3, 2, 3, 4, 4, 5]. The challenge arises when you consider an array you've modified with an unknown number of "Copy-Paste" actions, ending up with array A. The original sequence is a mystery to you, and your task is to deduce the smallest possible original sequence from which A could have been derived using the "Copy-Paste" operation.

Input

The challenge begins with an integer T, representing the number of test scenarios you'll explore. Following this, each scenario is introduced with its own integer N, indicating the total elements within the resulting array A. A subsequent line lists N space-separated integers A₁, A₂, ..., Aₙ, making up the array.

Output

Your goal for each scenario is to provide the minimal initial sequence length from which the final array A could have been obtained through "Copy-Paste" maneuvers.

Boundaries to consider:

  • 1 ≤ T ≤ 20
  • 1 ≤ N ≤ 10^5
  • 1 ≤ Aᵢ ≤ 10^5

Sample Scenarios:

Scenario #1:

Input:

2 5 1 1 1 1 1 5 1 2 3 1 2

Output:

1 3

Clarification:

In the premier scenario, the only conceivable origin is the array [1], which through successive "Copy-Paste" actions becomes [1, 1, 1, 1, 1]. In the subsequent scenario, the array A could stem from [1, 2, 3], with the initial two elements copied to the end.