**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Unique Array
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given an integer array $$$a$$$ of length $$$n$$$. A subarray of $$$a$$$ is one of its contiguous subsequences (i. e. an array $$$[a_l, a_{l+1}, \dots, a_r]$$$ for some integers $$$l$$$ and $$$r$$$ such that $$$1 \le l < r \le n$$$). Let's call a subarray unique if there is an integer that occurs exactly once in the subarray.

You can perform the following operation any number of times (possibly zero): choose an element of the array and replace it with any integer.

Your task is to calculate the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Examples:
input:
4
3
2 1 2
4
4 4 4 4
5
3 1 2 1 2
5
1 3 2 1 2
output:
0
2
1
0

Note: In the second test case, you can replace the $$$1$$$-st and the $$$3$$$-rd element, for example, like this: $$$[3, 4, 1, 4]$$$.

In the third test case, you can replace the $$$4$$$-th element, for example, like this: $$$[3, 1, 2, 3, 2]$$$.

Buggy Code:
import java.io.*;
import java.util.*;

public class E {

	static IOHandler sc = new IOHandler();
	static PrintWriter out = new PrintWriter(System.out);
	static int tc;

	public static void main(String[] args) throws IOException {

        new Thread(null, new Solution(), "solution", 1 << 26 ).start();
    }

	private static class Solution implements Runnable {

		public void run() {
			// TODO Auto-generated method stub
			int testCases = sc.nextInt();
			tc = testCases;

			for (int i = 1; i <= testCases; ++i) {
				solve(i);
			}

			out.flush();
		}

		private void solve(int t) {
			// Read question and Test cases thoroughly
			// Check for overflow , Avoid Integer ==
			// Handle invalid cases
			// Think before solving
			// Search for concepts
			// expected alg like seg tree, trie, binSearch, sqrt decom ...

			int n = sc.nextInt();

			int [] arr = sc.readArray2(n);

			TreeSet<Integer> singles = new TreeSet<>();
			singles.add(0);

			Map<Integer, int []> map = new HashMap<>();
			int count = 0;
			int val;

			BIT lower = new BIT(n + 2);
			BIT higher = new BIT(n + 2);

			int [] cArr;
			int min;

			for (int i = 1; i <= n; ++i) {
				val = arr[i];

				if (!map.containsKey(val)) {
					singles.add(i);
					map.put(val, new int [] {i, 0});
				}else {
					cArr = map.get(val);
					singles.remove(cArr[0]);

					if (cArr[1] != 0) {
						lower.update(cArr[1], -1);
						higher.update(cArr[0], -1);
					}

					cArr[1] = cArr[0];
					cArr[0] = i;

					lower.update(cArr[1], 1);
					higher.update(cArr[0], 1);
				}

				min = singles.last() + 1;

				if (min <= i && lower.get(min) == higher.get(min)) {
					++count;
					singles = new TreeSet<>();
					singles.add(i);
					map = new HashMap<>();
				}

				//System.out.println(i);
			}

			if (tc < 100)
				out.println(count);
			else if (t == 149) {
				out.println(Arrays.toString(arr));
			}
		}
	}

	private static class BIT {

		long [] arr;

		BIT(int n){
			arr = new long [n + 1];
		}

		void update (int idx, long val) {
			for (int i = idx; i > 0; i -= (i & -i)) {
				arr[i] += val;
			}
		}

		long get(int idx) {
			long result = 0;

			for (int i = idx; i < arr.length; i += (i & -i)) {
				result += arr[i];
			}

			return result;
		}
	}

	private static class IOHandler {
      BufferedReader br;
      StringTokenizer st;

      public IOHandler() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }

      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }

      int nextInt() {
          return Integer.parseInt(next());
      }

      int [] readArray(int n) {
    	  int [] res = new int [n];

    	  for (int i = 0; i < n; ++i)
    		  res[i] = nextInt();

    	  return res;
      }

      int [] readArray2(int n) {
    	  int [] res = new int [n + 1];

    	  for (int i = 1; i <= n; ++i)
    		  res[i] = nextInt();

    	  return res;
      }

      int [][] readGraph(int n, int m, int c) {
    	  int [][] graph = new int [n + 1][];

    	  int [] count = new int [n + 1];
    	  int [][] arr = new int [m][1 + c];

    	  int a, b;

    	  for (int i = 0; i < m; ++i) {
    		  a = sc.nextInt();
    		  b = sc.nextInt();

    		  arr[i][0] = a;
    		  arr[i][1] = b;

    		  ++count[a];
    		  ++count[b];

    		  for (int j = 2; j <= c; ++j) {
    			  arr[i][j] = sc.nextInt();
    		  }
    	  }

    	  for (int i = 0; i <= n; ++i) {
    		  graph[i] = new int [count[i] * c];
    		  count[i] = 0;
    	  }
    	  int swap;

    	  for (int [] tArr : arr) {
    		  for (int j = 1; j < tArr.length; ++j) {
    			  graph[tArr[0]][count[tArr[0]]++] = tArr[j];
    		  }

    		  swap = tArr[0];
    		  tArr[0] = tArr[1];
    		  tArr[1] = swap;

    		  for (int j = 1; j < tArr.length; ++j) {
    			  graph[tArr[0]][count[tArr[0]]++] = tArr[j];
    		  }
    	  }

    	  return graph;
      }

      long nextLong() {
          return Long.parseLong(next());
      }

      double nextDouble() {
          return Double.parseDouble(next());
      }

      String nextLine(){
          String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
      }

   }

}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided buggy code, we need to focus on edge cases and scenarios that are likely to cause issues. Here are the steps to think through:

1. **Understand the Bug**: The buggy code seems to have issues with tracking the unique elements and their positions correctly. It might also have problems with handling large numbers of repeated elements and the data structures used (e.g., `TreeSet` and `BIT`).

2. **Edge Cases**:
   - **All Elements Are the Same**: This can expose issues with the logic for handling repeated elements.
   - **Elements with Frequent Repeats**: This can test the handling of multiple repeated elements.
   - **Edge Cases with Small Arrays**: Small arrays can help in verifying the correctness of the logic.
   - **Edge Cases with Large Arrays**: Large arrays can help in verifying the performance and correctness of the logic.

3. **Generate Test Input**:
   - We will create a small-scale test input that is complete and valid.
   - We will include a test case where all elements are the same.
   - We will include a test case with frequent repeats.
   - We will include a test case with a small array.

Here is the test input:

```plaintext
3
1
1
4
1 1 1 1
5
1 2 3 4 5
```

Explanation:
- **Test Case 1**: A single element array `[1]`. The expected output is `0` because the subarray is already unique.
- **Test Case 2**: An array with all elements the same `[1, 1, 1, 1]`. The expected output is `2` because we need to change two elements to make all subarrays unique.
- **Test Case 3**: An array with all unique elements `[1, 2, 3, 4, 5]`. The expected output is `0` because all subarrays are already unique.

This test input should help in exposing the bug in the provided buggy code.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Unique Array
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given an integer array $$$a$$$ of length $$$n$$$. A subarray of $$$a$$$ is one of its contiguous subsequences (i. e. an array $$$[a_l, a_{l+1}, \dots, a_r]$$$ for some integers $$$l$$$ and $$$r$$$ such that $$$1 \le l < r \le n$$$). Let's call a subarray unique if there is an integer that occurs exactly once in the subarray.

You can perform the following operation any number of times (possibly zero): choose an element of the array and replace it with any integer.

Your task is to calculate the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Examples:
input:
4
3
2 1 2
4
4 4 4 4
5
3 1 2 1 2
5
1 3 2 1 2
output:
0
2
1
0

Note: In the second test case, you can replace the $$$1$$$-st and the $$$3$$$-rd element, for example, like this: $$$[3, 4, 1, 4]$$$.

In the third test case, you can replace the $$$4$$$-th element, for example, like this: $$$[3, 1, 2, 3, 2]$$$.

Buggy Code:
import java.io.*;
import java.util.*;

public class E {

	static IOHandler sc = new IOHandler();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws IOException {

        new Thread(null, new Solution(), "solution", 1 << 26 ).start();
    }

	private static class Solution implements Runnable {

		public void run() {
			// TODO Auto-generated method stub
			int testCases = sc.nextInt();

			for (int i = 1; i <= testCases; ++i) {
				solve(i);
			}

			out.flush();
		}

		private void solve(int t) {
			// Read question and Test cases thoroughly
			// Check for overflow , Avoid Integer ==
			// Handle invalid cases
			// Think before solving
			// Search for concepts
			// expected alg like seg tree, trie, binSearch, sqrt decom ...

			int n = sc.nextInt();

			int [] arr = sc.readArray(n);

			Set<BitSet> set = new HashSet<>();

			BitSet current = new BitSet();

			set.add((BitSet)current.clone());

			int count = 0;

			BitSet next;

			for (int num : arr) {

				current.flip(num);
				next = (BitSet)current.clone();

				if (!set.add(next)) {
					++count;
					current = new BitSet();
					set = new HashSet<>();
					set.add((BitSet)current.clone());
				}
			}

			out.println(count);
		}
	}

	private static class IOHandler {
      BufferedReader br;
      StringTokenizer st;

      public IOHandler() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }

      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }

      int nextInt() {
          return Integer.parseInt(next());
      }

      int [] readArray(int n) {
    	  int [] res = new int [n];

    	  for (int i = 0; i < n; ++i)
    		  res[i] = nextInt();

    	  return res;
      }

      int [] readArray2(int n) {
    	  int [] res = new int [n + 1];

    	  for (int i = 1; i <= n; ++i)
    		  res[i] = nextInt();

    	  return res;
      }

      int [][] readGraph(int n, int m, int c) {
    	  int [][] graph = new int [n + 1][];

    	  int [] count = new int [n + 1];
    	  int [][] arr = new int [m][1 + c];

    	  int a, b;

    	  for (int i = 0; i < m; ++i) {
    		  a = sc.nextInt();
    		  b = sc.nextInt();

    		  arr[i][0] = a;
    		  arr[i][1] = b;

    		  ++count[a];
    		  ++count[b];

    		  for (int j = 2; j <= c; ++j) {
    			  arr[i][j] = sc.nextInt();
    		  }
    	  }

    	  for (int i = 0; i <= n; ++i) {
    		  graph[i] = new int [count[i] * c];
    		  count[i] = 0;
    	  }
    	  int swap;

    	  for (int [] tArr : arr) {
    		  for (int j = 1; j < tArr.length; ++j) {
    			  graph[tArr[0]][count[tArr[0]]++] = tArr[j];
    		  }

    		  swap = tArr[0];
    		  tArr[0] = tArr[1];
    		  tArr[1] = swap;

    		  for (int j = 1; j < tArr.length; ++j) {
    			  graph[tArr[0]][count[tArr[0]]++] = tArr[j];
    		  }
    	  }

    	  return graph;
      }

      long nextLong() {
          return Long.parseLong(next());
      }

      double nextDouble() {
          return Double.parseDouble(next());
      }

      String nextLine(){
          String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
      }

   }

}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided code, we need to focus on edge cases and scenarios that can cause the code to fail. The main issue in the code is the use of `BitSet` to track the elements in the subarray, which is not an appropriate data structure for this problem. The `BitSet` is used to track the presence of elements, but it doesn't handle the case where multiple elements are the same, which is crucial for the problem.

### Steps to Create the Test Input:
1. **Identify the Bug**: The code uses `BitSet` to track the elements in the subarray, but `BitSet` can only track the presence of elements, not their counts. This means it cannot distinguish between a subarray with multiple occurrences of the same element and a subarray with unique elements.

2. **Edge Case**: Create a test case where the array has multiple occurrences of the same element, which should require a significant number of operations to make all subarrays unique.

3. **Small-Scale Test Input**: Since we need a small-scale test input, we can use a small array with repeated elements.

### Chosen Test Input:
```plaintext
1
6
1 1 1 1 1 1
```

### Explanation:
- **Test Case 1**: The array consists of six elements, all of which are `1`.
- **Expected Output**: The minimum number of operations required to make all subarrays unique is `5`. This is because we need to change 5 out of the 6 elements to make all subarrays unique.

### Why This Test Input is Challenging:
- **Multiple Occurrences**: The array has multiple occurrences of the same element, which should require a significant number of operations to make all subarrays unique.
- **Edge Case**: The code using `BitSet` will fail to correctly count the number of operations needed because it cannot distinguish between multiple occurrences of the same element.

### Output:
```plaintext
1
6
1 1 1 1 1 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Unique Array
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given an integer array $$$a$$$ of length $$$n$$$. A subarray of $$$a$$$ is one of its contiguous subsequences (i. e. an array $$$[a_l, a_{l+1}, \dots, a_r]$$$ for some integers $$$l$$$ and $$$r$$$ such that $$$1 \le l < r \le n$$$). Let's call a subarray unique if there is an integer that occurs exactly once in the subarray.

You can perform the following operation any number of times (possibly zero): choose an element of the array and replace it with any integer.

Your task is to calculate the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Examples:
input:
4
3
2 1 2
4
4 4 4 4
5
3 1 2 1 2
5
1 3 2 1 2
output:
0
2
1
0

Note: In the second test case, you can replace the $$$1$$$-st and the $$$3$$$-rd element, for example, like this: $$$[3, 4, 1, 4]$$$.

In the third test case, you can replace the $$$4$$$-th element, for example, like this: $$$[3, 1, 2, 3, 2]$$$.

Buggy Code:
#include<bits/stdc++.h>
using namespace std;
#define time chrono::system_clock::now().time_since_epoch().count()
mt19937_64 rnd(time);
#define maxn 1000005
#define int long long

int read() {int x;cin>>x;return x;}
int mod1 = 998244353, mod2 = 1e9 + 7;

// struct Hash {
//     const int mod1 = 998244353, mod2 = 1e9 + 7;
//     int b1 = 17, b2 = 233, n;
//     vector<int> f1, f2, B1, B2;
//     Hash(){}
//     Hash(string s):n(s.length()), f1(n + 1), f2(n + 1), B1(n + 1), B2(n + 1) {
//         B1[0] = B2[0] = 1;
//         for(int i = 1; i <= n; i++) {
//             B1[i] = B1[i - 1] * b1 % mod1;
//             B2[i] = B2[i - 1] * b2 % mod2;
//             f1[i] = (f1[i - 1] * b1 + s[i] - 'a') % mod1;
//             f2[i] = (f2[i - 1] * b2 + s[i] - 'a') % mod2;
//         }
//     }
//     pair<int, int> get(int l, int r) {
//         int a1 = ((f1[r] - f1[l - 1] * B1[r - l + 1]) % mod1 + mod1) % mod1;
//         int a2 = ((f2[r] - f2[l - 1] * B2[r - l + 1]) % mod2 + mod2) % mod2;
//         return {a1, a2};
//     }
// };

int B1 = 1e6 + 9, B2 = 1e7 + 9;
int pw1[maxn], pw2[maxn];

void solve() {
    int n = read();
    vector<int> a(n + 1);
    map<int, int> vis;
    map<pair<int, int>, int> v;
    for(int i = 1; i <= n; i++) {
        a[i] = read();
    }

    int ans = 0;
    int val1 = 0, val2 = 0;
    v[{val1, val2}] = 1;
    for(int i = 1; i <= n; i++) {
        if(!vis[a[i]]) {
            vis[a[i]] = 1;
            val1 = (val1 + pw1[a[i]]) % mod1;
            val2 = (val2 + pw2[a[i]]) % mod2;
        }
        else if(vis[a[i]] == 1) {
            vis[a[i]] = 2;
            val1 = (val1 - pw1[a[i]] + mod1) % mod1;
            val2 = (val2 - pw2[a[i]] + mod2) % mod2;
        }
        // else continue;
        if(v.find({val1, val2}) != v.end()) {
            ans += 1;
            v.clear();
            vis.clear();
            val1 = 0; val2 = 0;
            v[{val1, val2}] = 1;
        }
        else {
            // cout << val1 << " " << val2  << "\n";
            v[{val1, val2}] = 1;
        }
    }
    cout << ans << "\n";

}

signed main() {
    pw1[0] = pw2[0] = 1;
    for(int i = 1; i <= 3e5; i++) {
        pw1[i] = pw1[i - 1] * B1 % mod1;
        pw2[i] = pw2[i - 1] * B2 % mod2;
    }
    #ifdef ONLINE_JUDGE
        ios::sync_with_stdio(false);
        cin.tie(0);cout.tie(0);
    #else
        //freopen("a.in", "r", stdin);
    #endif

    int t = read();
    while(t--) solve();
    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5
1 1 2 2 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Unique Array
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given an integer array $$$a$$$ of length $$$n$$$. A subarray of $$$a$$$ is one of its contiguous subsequences (i. e. an array $$$[a_l, a_{l+1}, \dots, a_r]$$$ for some integers $$$l$$$ and $$$r$$$ such that $$$1 \le l < r \le n$$$). Let's call a subarray unique if there is an integer that occurs exactly once in the subarray.

You can perform the following operation any number of times (possibly zero): choose an element of the array and replace it with any integer.

Your task is to calculate the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Examples:
input:
4
3
2 1 2
4
4 4 4 4
5
3 1 2 1 2
5
1 3 2 1 2
output:
0
2
1
0

Note: In the second test case, you can replace the $$$1$$$-st and the $$$3$$$-rd element, for example, like this: $$$[3, 4, 1, 4]$$$.

In the third test case, you can replace the $$$4$$$-th element, for example, like this: $$$[3, 1, 2, 3, 2]$$$.

Buggy Code:
// #include<atcoder/segtree.hpp>
// #include<atcoder/internal_bit>
// #include<atcoder/segtree>
// #include<atcoder/internal_bit.hpp>
// #include<lib/macros.h>
// #include<lib/vv.h>
// #include<lib/inp.h>
// #include<lib/common.h>
// #include<lib/print.h>
#ifndef DEBUG // Don't optimize locally
#pragma GCC optimize("O3")
#endif

#include <bits/stdc++.h>
// #include <iostream>
// #include <set>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
// #include <algorithm>
// #include <utility>
// #include <random>
// #include <climits>
// #include <numeric>
// #include <map>
// #include <chrono>
// #include <iomanip>

#include <cassert>
#include <cstdio>

using namespace std;

//  Definition of the macro.
// ass (a, b, x, y) is equivalent to a = x; b = y;
#define ass(a, b, x, y) (tie(a, b) = make_tuple(x, y));
// if x, y, z are ordered non-descendingly
#define ordered(x, y, z) ((x) <= (y) && (y) <= (z))

// updates lhs to be the minimum of lhs and rhs
template <typename T, typename S>
bool chkmin(T& lhs, S rhs)
{
    if (lhs > static_cast<T>(rhs)) {
        lhs = static_cast<T>(rhs);
        return true;
    } else {
        return false;
    }
}
// updates lhs to be the maximum of lhs and rhs
template <typename T, typename S>
bool chkmax(T& lhs, S rhs)
{
     if (lhs < static_cast<T>(rhs)) {
        lhs = static_cast<T>(rhs);
        return true;
    } else {
        return false;
    }
}

typedef long long ll;
// typedef __int128_t ll;

// Because unsigned sizes are absolutely stupid
// Got burned on 1841C
template <typename T>
inline ll len(const T& v)
{
    return ll(v.size());
}

#define to_str to_string
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define SLC(x, i1, i2) (x).begin() + i1, (x).begin() + i2

/**
 * Computes ceildiv, but handles negatives properly
*/
template <typename T, typename Y>
inline ll ceildiv(T x, Y y)
{
    if (y < 0) {
        return ceildiv(-x, -y);
    }
    if (x < 0) {
        return x / y;
    }
    return x / y + (x % y != 0);
}

/**
 * Computes floordiv, but handles negatives properly
*/
template <typename T, typename Y>
inline ll floordiv(T x, Y y)
{
    if (y < 0) {
        return floordiv(-x, -y);
    }
    if (x < 0) {
        return -ceildiv(-x, y);
    }
    return x / y;
}

// Looping
#define repe(i, d, u) for (ll i = (d); i < (u); ++i)
#define repi(i, d, u) for (ll i = (d); i <= (u); ++i)
#define dep(i, u, d) for (ll i = (u); i >= (d); --i)
#define irepi(i, d, u) for (i = (d); i <= (u); ++i)
#define irepe(i, d, u) for (i = (d); i < (u); ++i)
#define idep(i, u, d) for (i = (u); i >= (d); --i)
#define srepi(i, d, u, s) for (ll i = (d); i <= (u); i += s)
#define srepe(i, d, u, s) for (ll i = (d); i < (u); i += s)

#define cep(t) while (t--)
#define CEPEAT_CAT_(a, b) a##b
#define CEPEAT_CAT(a, b) CEPEAT_CAT_(a, b)
#define cepeat(t) repe(CEPEAT_CAT(CEPEAT_COPY, __COUNTER__), 0, t)

#define foreach(i, c) for (auto& i : c)
#define foreachp(k, v, c) for (auto& [k, v] : c)

// Loops over all submasks of mask m
#define foreach_subset(u, m) for (ll u=m; u >= 0; u = u == 0 ? -1 : (u - 1) & m)

// Looping through a container
#define walk(i, container) for (ll i = 0; i < len(container); ++i)
#define reverse_walk(i, container) for (ll i = len(container) - 1; i >= 0; --i)
#define iter_walk(i, container) for (auto i = container.begin(); i != container.end(); i++)
#define reverse_iter_walk(i, container) for (auto i = container.rbegin(); i != container.rend(); i++)

#define rep repe
#define srep srepe
#define irep irepe

#define FOR repi
#define DOR dep
#define SFOR srepi
#define IFOR irepi
#define IDOR idep

struct custom_hash {
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t do_hash(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }

    size_t operator()(uint64_t x) const
    {
        return do_hash(x);
    }

    template <typename T1, typename T2>
    size_t operator()(const std::pair<T1, T2>& key) const
    {
        return (do_hash(key.first) << 21) ^ do_hash(key.second);
    }

    size_t operator()(const string& s) const
    {
        uint64_t out = 0;
        for (int i = 0; i < len(s); i++) {
            out = out * 37 + s[i];
        }
        return do_hash(out);
    }

    template <typename T>
    size_t operator()(const vector<T>& vec) const
    {
        size_t seed = len(vec);
        for (auto& i : vec) {
            seed ^= (*this)(i) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
        }
        return seed;
    }

    template <long unsigned int T>
    size_t operator()(const bitset<T>& b) const
    {
        return do_hash(to_string(b));
    }

    template <typename T, size_t N>
    size_t operator()(const array<T, N>& a) const {
        size_t seed = len(a);
        for (auto& i : a) {
            seed ^= (*this)(i) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
        }
        return seed;
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/**
 * Generate a random number between a and b inclusive
 *
 * Ex: uid(4, 9);
*/
#define uid(a, b) uniform_int_distribution<ll>(a, b)(rng)

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef array<ll, 2> array2;
typedef array<ll, 3> array3;
typedef array<ll, 4> array4;

typedef vector<vector<ll>> vvl;
typedef vector<string> vstr;
typedef vector<vector<string>> vvstr;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef pair<int, int> pii;
typedef vector<vector<pl>> vvpl;
typedef vector<pl> vpl;
typedef vector<pi> vpi;
typedef vector<double> vd;
typedef vector<long double> vld;

// Maps
typedef unordered_map<ll, ll, custom_hash> umapll;
typedef unordered_map<ll, vl, custom_hash> umaplvl;
typedef unordered_map<string, ll, custom_hash> umapstrl;
typedef unordered_map<ll, string, custom_hash> umaplstr;
template <typename K, typename V>
using umap = unordered_map<K, V, custom_hash>;

typedef unordered_set<ll, custom_hash> usetl;
template <typename K>
using uset = unordered_set<K, custom_hash>;

template <typename T>
using maxheap = priority_queue<T, vector<T>, less<T>>;
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;

/**
 * Allows addition of dicts. Merges and adds values when keys overlap.
*/
template <typename K, typename V>
umap<K, V> operator+(const umap<K, V>& lhs, const umap<K, V>& rhs)
{
    umap<K, V> result = lhs;

    for (const auto& pair : rhs) {
        result[pair.first] += pair.second;
    }

    return result;
}

/**
 * Extract value from a map without modification.
 *
 * Ex. map << 5
 * is equivalent to map[5], but it does not insert the 5 into the map
 * if it is not there
*/
template <typename Key, typename Value>
Value operator<<(const umap<Key, Value>& map, const Key& key)
{
    auto it = map.find(key);
    if (it != map.end()) {
        return it->second;
    }
    return Value {}; // Default-constructed value
}

template <typename Key, typename Value>
Value operator<<(const std::map<Key, Value>& map, const Key& key)
{
    auto it = map.find(key);
    if (it != map.end()) {
        return it->second;
    }
    return Value {}; // Default-constructed value
}

template <typename K, typename V>
void initmap(umap<K, V>& counts)
{
    counts.reserve(250000);
    counts.max_load_factor(0.25);
}

#define RC(expr, x, lo, hi) ({                                \
    ll x;                                                     \
    using RC_t = std::remove_reference<decltype(expr)>::type; \
    vector<RC_t> lcret;                                       \
    IFOR(x, lo, hi)                                           \
    {                                                         \
        lcret.push_back(expr);                                \
    }                                                         \
    lcret;                                                    \
})

#define LC(expr, x, arr) ({                                               \
    using LCx_t = std::remove_reference<decltype(arr)>::type::value_type; \
    LCx_t x;                                                              \
    using LCexpr_t = std::remove_reference<decltype(expr)>::type;         \
    vector<LCexpr_t> lcret;                                               \
    foreach (LC_i, arr) {                                                 \
        x = LC_i; /*Using LC_i and then x = LC_i pacifies -Wshadow*/      \
        lcret.push_back(expr);                                            \
    }                                                                     \
    lcret;                                                                \
})

// The first 4 directions are the normal up down left right
// the next 4 are diagonal directions, if you need that too
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1,  -1, -1 };

// Binary Search
// NOTE: lo and hi are inclusive;
// Eg. largest_st(x, a[x] < 5, 0, 10) will search for x between [0, 10]
#define largest_st(mid, cond, lo, hi) ({                          \
    ll BISEARCH_l = (lo), BISEARCH_r = (hi), BISEARCH_ans = (hi); \
    ll mid;                                                       \
    while (BISEARCH_l <= BISEARCH_r) {                            \
        mid = (BISEARCH_l + BISEARCH_r) / 2;                      \
        if ((cond)) {                                             \
            BISEARCH_ans = (mid);                                 \
            BISEARCH_l = (mid) + 1;                               \
        } else {                                                  \
            BISEARCH_r = (mid)-1;                                 \
        }                                                         \
    }                                                             \
    mid = BISEARCH_ans;                                           \
    if (!((cond))) {                                              \
        BISEARCH_ans = (lo)-1;                                    \
    }                                                             \
    BISEARCH_ans;                                                 \
})

#define smallest_st(mid, cond, lo, hi) ({                         \
    ll BISEARCH_l = (lo), BISEARCH_r = (hi), BISEARCH_ans = (hi); \
    ll mid;                                                       \
    while (BISEARCH_l <= BISEARCH_r) {                            \
        mid = (BISEARCH_l + BISEARCH_r) / 2;                      \
        if ((cond)) {                                             \
            BISEARCH_ans = (mid);                                 \
            BISEARCH_r = (mid)-1;                                 \
        } else {                                                  \
            BISEARCH_l = (mid) + 1;                               \
        }                                                         \
    }                                                             \
    mid = BISEARCH_ans;                                           \
    if (!((cond))) {                                              \
        BISEARCH_ans = (hi) + 1;                                  \
    }                                                             \
    BISEARCH_ans;                                                 \
})

// Linear search
// Note that these are inclusive: [lo, hi]
#define first_st(x, cond, lo, hi) ({                     \
    ll _INTERNAL_start = (lo);                           \
    ll _INTERNAL_end = (hi);                             \
    ll x;                                                \
    for (x = _INTERNAL_start; x <= _INTERNAL_end; x++) { \
        if (cond)                                        \
            break;                                       \
    }                                                    \
    x;                                                   \
})

#define last_st(x, cond, hi, lo) ({                      \
    ll _INTERNAL_start = (lo);                           \
    ll _INTERNAL_end = (hi);                             \
    ll x;                                                \
    for (x = _INTERNAL_end; x >= _INTERNAL_start; x--) { \
        if (cond)                                        \
            break;                                       \
    }                                                    \
    x;                                                   \
})

// Existential/Universal linear search
#define exists_st(x, cond, lo, hi) ({                    \
    bool _INTERNAL_any_good = false;                     \
    ll _INTERNAL_start = (lo);                           \
    ll _INTERNAL_end = (hi);                             \
    ll x;                                                \
    for (x = _INTERNAL_start; x <= _INTERNAL_end; x++) { \
        _INTERNAL_any_good |= (cond);                    \
    }                                                    \
    _INTERNAL_any_good;                                  \
})

#define all_st(x, cond, lo, hi) ({                       \
    bool _INTERNAL_all_good = true;                      \
    ll _INTERNAL_start = (lo);                           \
    ll _INTERNAL_end = (hi);                             \
    ll x;                                                \
    for (x = _INTERNAL_start; x <= _INTERNAL_end; x++) { \
        _INTERNAL_all_good &= (cond);                    \
    }                                                    \
    _INTERNAL_all_good;                                  \
})

// Fixed iteration continuous binary search (largest_st)
#define largest_double_st(mid, cond, lo, hi, num_iterations) ({ \
    double BISEARCH_LO = (lo);                                   \
    double BISEARCH_HI = (hi);                                   \
    double mid;                                                  \
    cepeat((num_iterations))                                     \
    {                                                            \
        mid = (BISEARCH_LO + BISEARCH_HI) / 2.0;                 \
        if ((cond)) {                                            \
            BISEARCH_LO = mid;                                   \
        } else {                                                 \
            BISEARCH_HI = mid;                                   \
        }                                                        \
    }                                                            \
    mid;                                                         \
})
// Fixed iteration continuous binary search (smallest_st)
#define smallest_double_st(mid, cond, lo, hi, num_iterations) ({ \
    double BISEARCH_LO = (lo);                                   \
    double BISEARCH_HI = (hi);                                   \
    double mid;                                                  \
    cepeat((num_iterations))                                     \
    {                                                            \
        mid = (BISEARCH_LO + BISEARCH_HI) / 2.0;                 \
        if ((cond)) {                                            \
            BISEARCH_HI = mid;                                   \
        } else {                                                 \
            BISEARCH_LO = mid;                                   \
        }                                                        \
    }                                                            \
    mid;                                                         \
})
// does % but doesn't mess up negatives
//  mod(4, 5) == mod(-1, 5) == mod(-6, 5)
template <typename T=ll, typename S=ll>
T mod(T a, S p)
{
    if (p > 0) {
        return (a % p + p) % p;
    }
    return a;
}

// important constant to set for some problems
const ll MOD = 998244353LL;
// const ll MOD = 1000000007;

template <typename T=ll>
T mod(T a)
{
    return mod(a, MOD);
}
template <typename T=ll, typename S=ll>
void chkmod(T& a, S m = MOD)
{
    a = mod(a, m);
}

/**
 * Clipped multiplication (cmul)
 *
 * Returns a * b, unless a * b will overflow, in which case it
 * clips it between LONG_LONG_MIN and LONG_LONG_MAX
*/
ll cmul(ll a, ll b)
{
    if (b == 0)
        return 0;
    if (b > 0) {
        if (a >= LONG_LONG_MAX / b) {
            return LONG_LONG_MAX;
        } else if (a <= LONG_LONG_MIN / b) {
            return LONG_LONG_MIN;
        }
        return a * b;
    }
    // b is negative
    if (a <= LONG_LONG_MAX / b) {
        return LONG_LONG_MAX;
    } else if (a >= LONG_LONG_MIN / b) {
        return LONG_LONG_MIN;
    }
    return a * b;
}

#define ITERATE_BORDER(arr, i_var, j_var, expr) \
    ll i_var = 0; \
    ll j_var = 0; \
    IFOR(i_var, 0, len(arr) - 1) expr \
    j_var = len(arr[0]) - 1; \
    IFOR(i_var, 0, len(arr) - 1) expr \
    i_var = 0; \
    IFOR(j_var, 1, len(arr[0]) - 2) expr \
    i_var = len(arr) - 1; \
    IFOR(j_var, 1, len(arr[0]) - 2) expr

// Function to calculate (base^exponent) using repeated squaring
template <typename T1=ll, typename T2=ll>
typename std::enable_if<!std::is_same<T1, int>::value, T1>::type
power(T1 base, T2 exponent,
      function<T1(T1, T1)> mul=[](T1 x, T1 y) { return x * y; },
      function<T1()> e=[]() { return T1(1); })
{
    T1 result = e();

    while (exponent > 0) {
        // If the exponent is odd, multiply the result by base
        if (exponent & 1) {
            result = mul(result, base);
        }
        exponent >>= 1;
        if (exponent == 0) {
            break;
        }

        // Square the base and reduce the exponent by half
        base = mul(base, base);
    }

    return result;
}

template <typename T2=ll>
ll power(int base, T2 exponent,
         function<ll(ll, ll)> mul=[](ll x, ll y) { return x * y; },
         function<ll()> e=[]() { return 1LL; })
{
    return power<ll, T2>(ll(base), exponent, mul, e);
}

ll cpower(ll base, ll exponent) {
    return power<ll, ll>(base, exponent, cmul);
}

// Printing
void init()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    cout << setprecision(16) << std::fixed;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
#ifndef ONLINE_JUDGE
#ifdef DEBUG
    return os << "(" << p.first << ", " << p.second << ")";
#else
    return os << p.first << " " << p.second;
#endif
#else
    return os << p.first << " " << p.second;
#endif
}

template <typename K, typename V>
std::ostream &operator<<(std::ostream &os, const unordered_map<K, V, custom_hash> &mp)
{
    os << "{ ";
    for (const auto &p : mp)
    {
        os << p.first << ": " << p.second << ", ";
    }
    os << "}";
    return os;
}

template <typename K, typename V>
std::ostream &operator<<(std::ostream &os, const map<K, V> &mp)
{
    os << "{ ";
    for (const auto &p : mp)
    {
        os << p.first << ": " << p.second << ", ";
    }
    os << "}";
    return os;
}

template <typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v)
{
    for (auto it = v.begin(); it != v.end(); ++it)
    {
        os << *it;
        if (it != v.end() - 1)
        {
            os << " ";
        }
    }
    return os;
}

template <typename T>
std::ostream &operator<<(std::ostream &os, const std::deque<T> &v)
{
    for (auto it = v.begin(); it != v.end(); ++it)
    {
        os << *it;
        if (it != v.end() - 1)
        {
            os << " ";
        }
    }
    return os;
}

template <typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<std::vector<T>> &vv)
{
    walk(i, vv)
    {
#ifndef ONLINE_JUDGE
#ifdef DEBUG
        os << i << ": ";
#endif
#endif
        os << vv[i];
        if (i != len(vv) - 1)
        {
            os << '\n';
        }
    }
    return os;
}

template <typename T, size_t N>
std::ostream &operator<<(std::ostream& os, const array<T, N>& a) {
    FOR(i, 0, (int) N - 1) {
        cout << a[i];
        if (i < (int) N - 1) cout << " ";
    }
    return os;
}

template <typename T>
std::ostream &operator<<(std::ostream &os, const std::set<T> &s)
{
    os << "{ ";
    for (const auto &item : s)
    {
        os << item << " ";
    }
    os << "}";
    return os;
}

template <typename T>
std::ostream &operator<<(std::ostream &os, const std::multiset<T> &s)
{
    os << "{ ";
    for (const auto &item : s)
    {
        os << item << " ";
    }
    os << "}";
    return os;
}

template <typename T>
std::ostream &operator<<(std::ostream &os, const std::unordered_set<T, custom_hash> &s)
{
    os << "{ ";
    for (const auto &item : s)
    {
        os << item << " ";
    }
    os << "}";
    return os;
}

template <typename K, typename V>
std::ostream &operator<<(std::ostream &os, const std::unordered_map<K, V> &mp)
{
    os << "{ ";
    for (const auto &p : mp)
    {
        os << p.first << ": " << p.second << ", ";
    }
    os << "}";
    return os;
}

template <typename T>
void print(const T &t)
{
#ifdef INTERACTIVE
    std::cout << t << std::endl;
#else
#ifdef DEBUG
    std::cout << t << std::endl;
#else
    std::cout << t << "\n";
#endif
#endif
}

template <typename T, typename... Args>
void print(const T &t, const Args &...args)
{
    std::cout << t << " ";
    print(args...);
}

template <typename T>
void dprint(const T &t)
{
#ifndef ONLINE_JUDGE
#ifdef DEBUG
    std::cout << t << std::endl;
#endif
#endif
}

template <typename T, typename... Args>
void dprint(const T &t, const Args &...args)
{
#ifndef ONLINE_JUDGE
#ifdef DEBUG
    std::cout << t << " ";
    print(args...);
#endif
#endif
}

// Fancy variable debugging, stolen from:
// https://codeforces.com/blog/entry/79024
#ifndef ONLINE_JUDGE
#ifdef DEBUG
int recur_depth = 0;
#define dbg(x)                                                                                \
    {                                                                                \
        ++recur_depth;                                                                                \
        auto x_ = x;                                                                                \
        --recur_depth;                                                                                \
        cout << string(recur_depth, '\t') << #x << " = " << x_ << endl; \
    }
#else
#define dbg(x)
#endif
#else
#define dbg(x)
#endif

template <typename S, typename T>
istream &operator>>(istream &input, pair<S, T> &p)
{
    input >> p.first >> p.second;
    return input;
}

template <typename T>
istream &operator>>(istream &input, vector<T> &vec)
{
    for (auto &element : vec)
    {
        input >> element;
    }
    return input;
}

template<typename T>
istream& operator>>(istream& input, deque<T>& vec) {
    for (auto& element : vec) {
        input >> element;
    }
    return input;
}

// Input
namespace inp
{
    long long binary()
    {
        string s;
        cin >> s;
        long long res = 0;
        for (char c : s)
        {
            res <<= 1;
            if (c == '1')
                res |= 1;
        }
        return res;
    }

    template <typename T>
    void read1(vector<T>& v) {
        FOR(i, 1, len(v) - 1) {
            cin >> v[i];
        }
    }

    // forward means the input is parsed as
    // b[0], b[1], ..., b[n - 1]
    // backwards means the input is parsed as
    // b[n - 1], b[n - 2], ..., b[0]
    template <size_t N>
    void read_bitset(bitset<N>& b, int n, bool reverse=false) {
        char ch;
        if (!reverse) {
            FOR(i, 0, n - 1) {
                cin >> ch;
                b[i] = ch == '1';
            }
        }
        else {
            DOR(i, n - 1, 0) {
                cin >> ch;
                b[i] = ch == '1';
            }
        }
    }

    void read_tree(vvpl& graph) {
        ll n = len(graph);
        FOR(i, 0, n - 2) {
            ll u, v; cin >> u >> v;
            u--; v--;
            graph[u].pb({v, 1});
            graph[v].pb({u, 1});
        }
    }

    template<typename T>
    void read(T& t) {
        cin >> t;
    }

    template<typename T, typename... Args>
    void read(T& t, Args&... args) {
        cin >> t;
        read(args...);
    }
}

template <typename T>
struct Identity {
    constexpr const T& operator()(const T& value) const
    {
        return value;
    }
};

// Personal vectors
namespace vv {
template <typename T>
bool contains(const vector<T>& vec, const T& value)
{
    auto it = std::find(vec.begin(), vec.end(), value);
    return (it != vec.end());
}

template <typename S, typename T>
int indexof(const vector<T>& a, const S& element)
{
    for (int i = 0; i < len(a); ++i) {
        if (a[i] == element) {
            return i;
        }
    }
    return -1;
}

template <typename T>
inline vector<T> arange(T start, T end, T step = 1)
{
    vector<T> result;
    for (T value = start; value <= end; value += step) {
        result.pb(value);
    }
    return result;
}

template <typename T>
unordered_map<T, ll, custom_hash> counter(const vector<T>& a, ll start = 0, ll end = -1)
{
    if (start < 0) {
        start += len(a);
    }
    if (end < 0) {
        end += len(a);
    }

    unordered_map<T, ll, custom_hash> result;
    FOR(i, start, end)
    {
        result[a[i]]++;
    }

    return result;
}

// returns a sliced vector, a[start:end]
// behaves like python slicing (the slice is from [start, end))
template <typename T>
vector<T> slc(const vector<T>& a, int start = 0, int end = -1)
{
    if (start < 0) {
        start += len(a);
    }
    if (end < 0) {
        end += len(a);
    }
    return vector<T>(a.begin() + start, a.begin() + (end + 1));
}

// returns a subvector of a, defined by the indices in idx
template <typename T, typename S>
vector<T> slc(const vector<T>& a, const vector<S> idx)
{
    ll length = len(idx);
    vector<T> result(length);
    for (int i = 0; i < length; i++) {
        result[i] = a[idx[i]];
    }
    return result;
}

template <typename T>
bool all(const vector<T>& a)
{
    return std::all_of(a.begin(), a.end(), [](bool b) { return b; });
}

template <typename T>
bool any(const vector<T>& a)
{
    return std::any_of(a.begin(), a.end(), [](bool b) { return b; });
}

template <typename T>
T sum(const vector<T>& a, int start = 0, int end = -1)
{
    if (end < 0) {
        end = len(a) + end;
    }
    return std::accumulate(a.begin() + start, a.begin() + end + 1, T(0));
}

template <typename T>
T prod(const vector<T>& a, int start = 0, int end = -1, ll mm = -1)
{
    if (end < 0) {
        end = len(a) + end;
    }
    T p(1);
    FOR(i, start, end)
    {
        p = p * a[i];
        if (mm > 0) {
            p %= mm;
        }
    }
    return p;
}

template <typename T>
T XOR(const vector<T>& a, int start = 0, int end = -1)
{
    if (end < 0) {
        end = len(a) + end;
    }
    T p(0);
    FOR(i, start, end)
    {
        p = p ^ a[i];
    }
    return p;
}

template <typename T>
T min(const vector<T>& a, int start = 0, int end = -1)
{
    if (start < 0) {
        start += len(a);
    }
    if (end < 0) {
        end += len(a);
    }

    T ans = a[start];
    FOR(i, start + 1, end)
    {
        ans = std::min(ans, a[i]);
    }
    return ans;
}

template <typename T>
T max(const vector<T>& a, int start = 0, int end = -1)
{
    if (start < 0) {
        start += len(a);
    }
    if (end < 0) {
        end += len(a);
    }

    T ans = a[start];
    FOR(i, start + 1, end)
    {
        ans = std::max(ans, a[i]);
    }
    return ans;
}

template <typename T, typename KeyFunc = Identity<T>>
void sort(vector<T>& a, int start = 0, int end = -1, KeyFunc keyFunc = Identity<T> {})
{
    if (end < 0) {
        end += len(a);
    }
    if (start >= end || end >= len(a)) {
        return; // Invalid indices or empty range
    }

    std::stable_sort(a.begin() + start, a.begin() + end + 1,
        [&keyFunc](const T& x, const T& y) {
            return keyFunc(x) < keyFunc(y);
        });
}

template <typename T, typename KeyFunc = Identity<T>>
void rsort(vector<T>& a, int start = 0, int end = -1, KeyFunc keyFunc = Identity<T> {})
{
    if (end < 0) {
        end += len(a);
    }
    if (start >= end || end >= len(a)) {
        return; // Invalid indices or empty range
    }

    std::stable_sort(a.begin() + start, a.begin() + end + 1,
        [&keyFunc](const T& x, const T& y) {
            return keyFunc(x) > keyFunc(y);
        });
}

template <typename T>
vector<int> argsort(const vector<T>& a)
{
    // Initialize original index positions
    vector<int> indices(a.size());
    for (int i = 0; i < len(indices); ++i) {
        indices[i] = i;
    }

    // Sort the indices based on comparing array values
    std::stable_sort(indices.begin(), indices.end(), [&](int i1, int i2) { return a[i1] < a[i2]; });

    return indices;
}

// returns the index of the maximum element
// if earliest is true, then return the earliest maximum element when there is a tie.
template <typename T>
int argmax(const vector<T>& a, ll start = 0, ll end = -1, bool earliest = true)
{
    if (start < 0) {
        start += len(a);
    }
    if (end < 0) {
        end += len(a);
    }
    T best = a[start];
    int best_idx = start;
    FOR(i, start, end)
    {
        if (earliest ? (a[i] > best) : (a[i] >= best)) {
            best_idx = i;
            best = a[i];
        }
    }
    return best_idx;
}

// returns the index of the smallest element
// if earliest is true, then return the earliest smallest element when there is a tie.
template <typename T>
int argmin(const vector<T>& a, ll start = 0, ll end = -1, bool earliest = true)
{
    if (start < 0) {
        start += len(a);
    }
    if (end < 0) {
        end += len(a);
    }
    T best = a[start];
    int best_idx = start;
    FOR(i, start, end)
    {
        if (earliest ? (a[i] < best) : (a[i] <= best)) {
            best_idx = i;
            best = a[i];
        }
    }
    return best_idx;
}

template <typename S, typename T>
void fill(vector<T>& a, S elem)
{
    FOR(i, 0, len(a) - 1)
    {
        a[i] = elem;
    }
}

template <typename T>
vector<T> cumsum(const vector<T>& a, bool reverse = false)
{
    vector<T> ret(a);
    if (reverse) {
        DOR(i, len(a) - 2, 0)
        {
            ret[i] += ret[i + 1];
        }
    } else {
        FOR(i, 1, len(a) - 1)
        {
            ret[i] += ret[i - 1];
        }
    }
    return ret;
}

template <typename T>
vector<T> cummax(const vector<T>& a, bool reverse = false)
{
    vector<T> ret(a);
    ll n = len(a);
    if (reverse) {
        DOR(i, n - 2, 0)
        {
            ret[i] = std::max(ret[i + 1], ret[i]);
        }
    } else {
        FOR(i, 1, n - 1)
        {
            ret[i] = std::max(ret[i], ret[i - 1]);
        }
    }
    return ret;
}

template <typename T>
vector<T> cumxor(const vector<T>& a, bool reverse = false)
{
    vector<T> ret(a);
    if (reverse) {
        DOR(i, len(a) - 2, 0)
        {
            ret[i] ^= ret[i + 1];
        }
    } else {
        FOR(i, 1, len(a) - 1)
        {
            ret[i] ^= ret[i - 1];
        }
    }
    return ret;
}

template <typename T>
vector<T> cummin(const vector<T>& a, bool reverse = false)
{
    vector<T> ret(a);
    ll n = len(a);
    if (reverse) {
        DOR(i, n - 2, 0)
        {
            ret[i] = std::min(ret[i + 1], ret[i]);
        }
    } else {
        FOR(i, 1, n - 1)
        {
            ret[i] = std::min(ret[i], ret[i - 1]);
        }
    }
    return ret;
}

template <typename T>
vector<T> cumprod(const vector<T>& a, bool reverse = false)
{
    vector<T> ret(a);
    ll n = len(a);
    if (reverse) {
        DOR(i, n - 2, 0)
        {
            ret[i] *= ret[i + 1];
        }
    } else {
        FOR(i, 1, n - 1)
        {
            ret[i] *= ret[i - 1];
        }
    }
    return ret;
}

vl cumcprod(const vl& a, bool reverse = false)
{
    vl ret(a);
    ll n = len(a);
    if (reverse) {
        DOR(i, n - 2, 0)
        {
            ret[i] = cmul(ret[i + 1], ret[i]);
        }
    } else {
        FOR(i, 1, n - 1)
        {
            ret[i] = cmul(ret[i - 1], ret[i]);
        }
    }
    return ret;
}
template <typename T>
bool is_lex_less(const vector<T>& a, const vector<T>& perm)
{
    // Compare the permutations lexicographically
    return std::lexicographical_compare(a.begin(), a.end(), perm.begin(), perm.end());
}

template <typename T>
vector<pair<T, ll>> with_idx(const vector<T>& a)
{
    vector<pair<T, ll>> out;
    ll n = len(a);
    FOR(i, 0, n - 1)
    {
        out.pb(mp(a[i], i));
    }
    return out;
}

template <typename T, typename S>
void push_front(vector<T>& a, S val) {
    a.insert(a.begin(), T(val));
}

vector<ll> to_vl(const vector<int>& v) {
    return LC((ll) x, x, v);
}

template <typename T>
vector<ll> coord_compress(const vector<T>& a, bool dedupe = true) {
    if(dedupe)
    {
        vi s_idx = argsort(a);
        umap<T, ll> coord;
        ll idx = 0;
        foreach(xi, s_idx) {
            T x = a[xi];
            if (coord.count(x) == 0) {
                coord[x] = idx;
                idx++;
            }
        }
        vl result(len(a));
        walk(i, a) {
            result[i] = coord[a[i]];
        }
        return result;
    }
    else
    {
        return to_vl(argsort(argsort(a)));
    }
}

template <typename T>
ll mex(const vector<T>& a, bool positive=false) {
    ll n = len(a);
    ll start = int(positive);
    vb exists(start + n);
    FOR(i, 0, n - 1) {
        if (a[i] >= n + start) continue;
        exists[a[i]] = true;
    }
    FOR(i, start, n - 1 + start) {
        if (!exists[i]) return i;
    }
    return n + start;
}

template <typename T>
std::vector<T> unique(const std::vector<T>& input) {
    std::set<T> uniqueSet(input.begin(), input.end());
    std::vector<T> uniqueVector(uniqueSet.begin(), uniqueSet.end());
    return uniqueVector;
}

/**
 * Inverts the permutation in p.
 *
 * Returns an array a such that p[a[i]] = a[p[i]] = i
*/
template <typename T>
std::vector<T> invperm(const std::vector<T>& p) {
    vector<T> a(len(p));
    walk(i, p) {
        a[p[i]] = i;
    }
    return a;
}

}; // namespace vv

#include <algorithm>
#include <cassert>
#include <functional>
#include <vector>

#ifdef _MSC_VER
#include <intrin.h>
#endif

#if __cplusplus >= 202002L
#include <bit>
#endif

namespace atcoder {

namespace internal {

#if __cplusplus >= 202002L

using std::bit_ceil;

#else

unsigned int bit_ceil(unsigned int n) {
    unsigned int x = 1;
    while (x < (unsigned int)(n)) x *= 2;
    return x;
}

#endif

int countr_zero(unsigned int n) {
#ifdef _MSC_VER
    unsigned long index;
    _BitScanForward(&index, n);
    return index;
#else
    return __builtin_ctz(n);
#endif
}

constexpr int countr_zero_constexpr(unsigned int n) {
    int x = 0;
    while (!(n & (1 << x))) x++;
    return x;
}

}  // namespace internal

}  // namespace atcoder

namespace atcoder {

#if __cplusplus >= 201703L

template <class S, auto op, auto e> struct segtree {
    static_assert(std::is_convertible_v<decltype(op), std::function<S(S, S)>>,
                  "op must work as S(S, S)");
    static_assert(std::is_convertible_v<decltype(e), std::function<S()>>,
                  "e must work as S()");

#else

template <class S, S (*op)(S, S), S (*e)()> struct segtree {

#endif

  public:
    segtree() : segtree(0) {}
    explicit segtree(int n) : segtree(std::vector<S>(n, e())) {}
    explicit segtree(const std::vector<S>& v) : _n(int(v.size())) {
        size = (int)internal::bit_ceil((unsigned int)(_n));
        log = internal::countr_zero((unsigned int)size);
        d = std::vector<S>(2 * size, e());
        for (int i = 0; i < _n; i++) d[size + i] = v[i];
        for (int i = size - 1; i >= 1; i--) {
            update_(i);
        }
    }

    void set(int p, S x) {
        assert(0 <= p && p < _n);
        p += size;
        d[p] = x;
        for (int i = 1; i <= log; i++) update_(p >> i);
    }

    /**
     * Equivalent to set(), just to match Rado interface.
    */
    void update(int p, S x) {
        set(p, x);
    }

    S get(int p) const {
        assert(0 <= p && p < _n);
        return d[p + size];
    }

    S prod(int l, int r) const {
        assert(0 <= l && l <= r && r <= _n);
        S sml = e(), smr = e();
        l += size;
        r += size;

        while (l < r) {
            if (l & 1) sml = op(sml, d[l++]);
            if (r & 1) smr = op(d[--r], smr);
            l >>= 1;
            r >>= 1;
        }
        return op(sml, smr);
    }

    /**
     * Endpoint inclusive!
    */
    S query(int l, int r) const {
        return prod(l, r + 1);
    }

    S all_prod() const { return d[1]; }

    S query_all() const {
        return all_prod();
    }

    template <bool (*f)(S)> int max_right(int l) const {
        return max_right(l, [](S x) { return f(x); });
    }
    template <class F> int max_right(int l, F f) const {
        assert(0 <= l && l <= _n);
        assert(f(e()));
        if (l == _n) return _n;
        l += size;
        S sm = e();
        do {
            while (l % 2 == 0) l >>= 1;
            if (!f(op(sm, d[l]))) {
                while (l < size) {
                    l = (2 * l);
                    if (f(op(sm, d[l]))) {
                        sm = op(sm, d[l]);
                        l++;
                    }
                }
                return l - size;
            }
            sm = op(sm, d[l]);
            l++;
        } while ((l & -l) != l);
        return _n;
    }

    template <bool (*f)(S)> int min_left(int r) const {
        return min_left(r, [](S x) { return f(x); });
    }
    template <class F> int min_left(int r, F f) const {
        assert(0 <= r && r <= _n);
        assert(f(e()));
        if (r == 0) return 0;
        r += size;
        S sm = e();
        do {
            r--;
            while (r > 1 && (r % 2)) r >>= 1;
            if (!f(op(d[r], sm))) {
                while (r < size) {
                    r = (2 * r + 1);
                    if (f(op(d[r], sm))) {
                        sm = op(d[r], sm);
                        r--;
                    }
                }
                return r + 1 - size;
            }
            sm = op(d[r], sm);
        } while ((r & -r) != r);
        return 0;
    }

  private:
    int _n, size, log;
    std::vector<S> d;

    void update_(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
};

}  // namespace atcoder

using namespace vv;

using S=ll;
S op(S a, S b) { return max(a, b); }

S e() { return -1; }

void solve() {
    ll n; cin >> n; vl a(n); cin >> a;
    vl nxt_index(n, n); {
        umapll data;
        DOR(i, n - 1, 0) {
            if (data.count(a[i])) {
                nxt_index[i] = data[a[i]];
            }
            data[a[i]] = i;
        }
    }

    ll ans = 0;
    atcoder::segtree<S, op, e> seg(nxt_index);
    ll r = n;
    DOR(i, n - 1, 0) {
        if (nxt_index[i] < r) {
            ll j = nxt_index[i];
            seg.update(j, -1);
            ll mx = seg.query(i + 1, j - 1);
            if (mx < r) {
                r = i;
                ans++;
            }
        }
    }
    print(ans);
}

int main() {
    init();
    int t; cin >> t;
    cep(t) solve();
    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input for the given buggy code, we need to focus on edge cases or scenarios that can expose potential bugs. Here are some considerations:

1. **Repeated Elements**: The code deals with finding the minimum number of operations to make all subarrays unique. A common issue in such problems is handling repeated elements efficiently.
2. **Edge Cases**: Test cases with the smallest and largest possible values for `n`.
3. **Special Patterns**: Test cases with specific patterns in the array, such as all elements being the same, or alternating elements.

Given these considerations, let's create a small-scale test input that is complete and valid:

1. **All Elements the Same**: This can cause issues in algorithms that do not handle repeated elements correctly.
2. **Alternating Elements**: This can test the algorithm's ability to handle periodic patterns.
3. **Mixed Elements**: A mix of repeated and unique elements to test the algorithm's robustness.

Here is a test input that combines these scenarios:

```plaintext
3
5
1 1 1 1 1
5
1 2 1 2 1
5
1 2 3 2 1
```

This input includes:
1. An array with all elements the same.
2. An array with alternating elements.
3. An array with a mix of repeated and unique elements.

This should help in exposing any bugs in the given code.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Unique Array
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given an integer array $$$a$$$ of length $$$n$$$. A subarray of $$$a$$$ is one of its contiguous subsequences (i. e. an array $$$[a_l, a_{l+1}, \dots, a_r]$$$ for some integers $$$l$$$ and $$$r$$$ such that $$$1 \le l < r \le n$$$). Let's call a subarray unique if there is an integer that occurs exactly once in the subarray.

You can perform the following operation any number of times (possibly zero): choose an element of the array and replace it with any integer.

Your task is to calculate the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Examples:
input:
4
3
2 1 2
4
4 4 4 4
5
3 1 2 1 2
5
1 3 2 1 2
output:
0
2
1
0

Note: In the second test case, you can replace the $$$1$$$-st and the $$$3$$$-rd element, for example, like this: $$$[3, 4, 1, 4]$$$.

In the third test case, you can replace the $$$4$$$-th element, for example, like this: $$$[3, 1, 2, 3, 2]$$$.

Buggy Code:
from collections import defaultdict
class DynamicSegmentTree:
    def __init__(self):
        self.cnt = defaultdict(int)
        self.todo = defaultdict(int)

    # 维护区间最大值
    def maintain(self, o: int) -> None:
        self.cnt[o] = min(self.cnt[o * 2], self.cnt[o * 2 + 1])

    def do(self, o: int, l: int, r: int, val: int) -> None:
        self.cnt[o] += val
        self.todo[o] += val

    def spread(self, o: int, l: int, r: int) -> None:
        v = self.todo[o]
        if v != 0:
            m = (l + r) // 2
            self.do(o * 2, l, m, v)
            self.do(o * 2 + 1, m + 1, r, v)
            self.todo[o] = 0

    # 区间 [L,R] 内的数都更新为 v   o,l,r=1,1,n
    def update(self, o: int, l: int, r: int, L: int, R: int, val: int) -> None:
        if L <= l and r <= R:
            self.do(o, l, r, val)
            return
        self.spread(o, l, r)
        m = (l + r) // 2
        if m >= L:
            self.update(o * 2, l, m, L, R, val)
        if m < R:
            self.update(o * 2 + 1, m + 1, r, L, R, val)
        self.maintain(o)

    def query(self, o: int, l: int, r: int, L: int, R: int) -> int:
        if L <= l and r <= R:
            return self.cnt[o]
        self.spread(o, l, r)
        m = (l + r) // 2
        res = 1
        if L <= m:
            res =  self.query(o * 2, l, m, L, R)
        if m < R:
            res = min(res,self.query(o * 2 + 1, m + 1, r, L, R))
        return res

def cf1969E():
    n = int(input())
    a = list(map(int, input().split()))
    st = DynamicSegmentTree()
    mx = n + 1
    p = [-1] * (n+1)
    p_last = [-1] * (n+1)
    s = 0
    ans = 0
    for r, x in enumerate(a):
        if p[x] >= s:
            st.update(1,0,mx,max(s, p_last[x]+1), p[x], -1)
        st.update(1,0,mx,max(s, p[x]+1), r, 1)
        if st.query(1,0,mx,s,r) == 0:
            ans += 1
            s = r+1
        p_last[x], p[x] = p[x], r

    print(ans)
    return

t = int(input())
for i in range(t):
    cf1969E()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
6
1 2 3 1 2 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Unique Array
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given an integer array $$$a$$$ of length $$$n$$$. A subarray of $$$a$$$ is one of its contiguous subsequences (i. e. an array $$$[a_l, a_{l+1}, \dots, a_r]$$$ for some integers $$$l$$$ and $$$r$$$ such that $$$1 \le l < r \le n$$$). Let's call a subarray unique if there is an integer that occurs exactly once in the subarray.

You can perform the following operation any number of times (possibly zero): choose an element of the array and replace it with any integer.

Your task is to calculate the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Examples:
input:
4
3
2 1 2
4
4 4 4 4
5
3 1 2 1 2
5
1 3 2 1 2
output:
0
2
1
0

Note: In the second test case, you can replace the $$$1$$$-st and the $$$3$$$-rd element, for example, like this: $$$[3, 4, 1, 4]$$$.

In the third test case, you can replace the $$$4$$$-th element, for example, like this: $$$[3, 1, 2, 3, 2]$$$.

Buggy Code:
def check(array):
    bool=False
    for i in array:
        if array.count(i)==1:
            bool=True
            break
    if bool:
        return bool,array.index(i)
    else:
        return bool,'no'

def min_oper(length,array):
    if length<=1:
        return 0

    if length==2:
        if array[0]==array[1]:
            return 1
        else:
            return 0

    else:
        bool,i=check(array)
        if bool:
            return min_oper(i,array[:i])+min_oper(length-i-1,array[i+1:])
        else:
            possibilities=[]
            for i in range(length):
                possibilities.append(min_oper(i,array[:i])+min_oper(length-i-1,array[i+1:]))
            return 1+min(possibilities)
test_cases=int(input())
for i in range(test_cases):
    length=int(input())
    array=input().split(' ')
    array=[int(x) for x in array]
    print(min_oper(length,array))

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
4
1
1
2
1 1
3
1 1 1
4
1 1 1 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Unique Array
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given an integer array $$$a$$$ of length $$$n$$$. A subarray of $$$a$$$ is one of its contiguous subsequences (i. e. an array $$$[a_l, a_{l+1}, \dots, a_r]$$$ for some integers $$$l$$$ and $$$r$$$ such that $$$1 \le l < r \le n$$$). Let's call a subarray unique if there is an integer that occurs exactly once in the subarray.

You can perform the following operation any number of times (possibly zero): choose an element of the array and replace it with any integer.

Your task is to calculate the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Examples:
input:
4
3
2 1 2
4
4 4 4 4
5
3 1 2 1 2
5
1 3 2 1 2
output:
0
2
1
0

Note: In the second test case, you can replace the $$$1$$$-st and the $$$3$$$-rd element, for example, like this: $$$[3, 4, 1, 4]$$$.

In the third test case, you can replace the $$$4$$$-th element, for example, like this: $$$[3, 1, 2, 3, 2]$$$.

Buggy Code:
import java.io.*;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        solver.solve(in.nextInt(), in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            for (int t = 0; t < testNumber; t++) {
                int n = in.nextInt();
                int[] a = new int[n];
                for (int i = 0; i < a.length; i++) {
                    a[i] = in.nextInt();
                }
                out.println(new Solution().solve(a));
            }
        }

        public void duiPai() {
            Random random = new Random();
            for (int t = 0; t < 100; t++) {
                int n = random.nextInt(10) + 5;
                int[] a = genArr(n, 1, 9);
                System.out.println(Arrays.toString(a));
            }
        }

        public int[] genArr(int n, int l, int r) {
            int[] arr = new int[n];
            Random random = new Random();
            for (int i = 0; i < n; i++) {
                arr[i] = random.nextInt(r - l + 1) + l;
            }
            return arr;
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

class Solution {
    public int solve(int[] a) {
        int n = a.length;
        int[] index = new int[n + 5];
        boolean[] vis = new boolean[n];
        Arrays.fill(index, -1);
        int[] pre = new int[n];
        for (int i = 0; i < n; i++) {
            pre[i] = index[a[i]];
            index[a[i]] = i;
        }
        LazySegmentTree st = new LazySegmentTree(new int[n]);
        int ans = 0;
        int max = -1;
        for (int i = 0; i < n; i++) {
            int p = pre[i];
            st.update(i, i, p);
            if (p <= max || vis[p]) {
                st.update(i, i, -1);
                continue;
            }
            st.update(p, p, p);
            int j = 0;
            int m = max;
            while (p > max) {
                int t = st.query(p + 1, i - 1);
                if (t >= p) {
                    break;
                }
                p = t;
                j++;
                if (j == 2) {
                    m = t;
                }
            }
            if (p <= max) {
                max = Math.max(max, m);
                continue;
            }
            vis[i] = true;
            st.update(i, i, -1);
            ans++;
        }
        return ans;
    }
}

class LazySegmentTree {
    private final int[] arr;
    private final int n;
    private final int[] tree;
    private final int[] lazy;
    private final boolean[] vis;

    public LazySegmentTree(int[] arr) {
        this.arr = arr;
        this.n = arr.length;
        tree = new int[4 * n];
        lazy = new int[4 * n];
        vis = new boolean[4 * n];
        build(1, 0, n - 1);
    }

    public void update(int i, int j, int v) {
        update(1, 0, n - 1, i, j, v);
    }

    public int query(int i, int j) {
        return query(1, 0, n - 1, i, j);
    }

    private void build(int p, int l, int r) {
        if (l == r) {
            tree[p] = arr[l];
            return;
        }
        int mid = (l + r) / 2;
        build(p * 2, l, mid);
        build(p * 2 + 1, mid + 1, r);
        pushUp(p);
    }

    private void pushUp(int p) {
        tree[p] = Math.min(tree[p * 2], tree[p * 2 + 1]);
    }

    private void pushDown(int p, int l, int r) {
        if (vis[p]) {
            tree[p * 2] = Math.min(tree[p * 2], lazy[p]);
            tree[p * 2 + 1] = Math.min(tree[p * 2 + 1], lazy[p]);
            lazy[p * 2] = lazy[p];
            lazy[p * 2 + 1] = lazy[p];
            vis[p] = false;
        }
    }

    private void update(int p, int l, int r, int i, int j, int v) {
        if (i <= l && j >= r) {
            tree[p] = v;
            lazy[p] = v;
            vis[p] = true;
            return;
        }
        pushDown(p, l, r);
        int mid = (l + r) / 2;
        if (i <= mid) {
            update(p * 2, l, mid, i, j, v);
        }
        if (j > mid) {
            update(p * 2 + 1, mid + 1, r, i, j, v);
        }
        pushUp(p);
    }

    private int query(int p, int l, int r, int i, int j) {
        if (i <= l && j >= r) {
            return tree[p];
        }
        pushDown(p, l, r);
        int mid = (l + r) / 2;
        int ans = Integer.MAX_VALUE / 2;
        if (i <= mid) {
            ans = Math.min(ans, query(p * 2, l, mid, i, j));
        }
        if (j > mid) {
            ans = Math.min(ans, query(p * 2 + 1, mid + 1, r, i, j));
        }
        return ans;
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the given buggy code, we need to consider scenarios where the algorithm might fail. The key points to focus on are:

1. **Repeating Elements**: The algorithm needs to handle cases where there are multiple repeating elements, especially when the same element appears more than twice.
2. **Edge Cases**: Test with small arrays and edge cases where the array has only one or two elements.
3. **Large Arrays**: Although the output length is limited, we can still generate a small but challenging array to test the algorithm's robustness.

Given these considerations, let's create a test input that includes multiple repeating elements and a few edge cases.

### Challenging Test Input
```plaintext
3
5
1 1 1 1 1
5
1 2 2 1 2
5
1 2 3 2 1
```

### Explanation
1. **Test Case 1: All Elements are the Same**
   - Array: `[1, 1, 1, 1, 1]`
   - This test case checks if the algorithm can handle a scenario where all elements are the same. The expected output is `4` because we need to change 4 elements to make all subarrays unique.

2. **Test Case 2: Multiple Repeating Elements with a Twist**
   - Array: `[1, 2, 2, 1, 2]`
   - This test case includes multiple repeating elements and checks if the algorithm can correctly identify the minimum number of changes needed. The expected output is `2` because we can change the first and last elements to make all subarrays unique.

3. **Test Case 3: Symmetrical Repeating Elements**
   - Array: `[1, 2, 3, 2, 1]`
   - This test case includes a symmetrical pattern of repeating elements. The expected output is `1` because we can change one of the `1`s to make all subarrays unique.

These test cases are designed to challenge the algorithm by exposing it to different patterns of repeating elements and edge cases.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Unique Array
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given an integer array $$$a$$$ of length $$$n$$$. A subarray of $$$a$$$ is one of its contiguous subsequences (i. e. an array $$$[a_l, a_{l+1}, \dots, a_r]$$$ for some integers $$$l$$$ and $$$r$$$ such that $$$1 \le l < r \le n$$$). Let's call a subarray unique if there is an integer that occurs exactly once in the subarray.

You can perform the following operation any number of times (possibly zero): choose an element of the array and replace it with any integer.

Your task is to calculate the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Input: The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.

The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$).

The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$).

Additional constraint on the input: the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

Output: For each test case, print a single integer — the minimum number of aforementioned operation in order for all the subarrays of the array $$$a$$$ to be unique.

Examples:
input:
4
3
2 1 2
4
4 4 4 4
5
3 1 2 1 2
5
1 3 2 1 2
output:
0
2
1
0

Note: In the second test case, you can replace the $$$1$$$-st and the $$$3$$$-rd element, for example, like this: $$$[3, 4, 1, 4]$$$.

In the third test case, you can replace the $$$4$$$-th element, for example, like this: $$$[3, 1, 2, 3, 2]$$$.

Buggy Code:
import java.io.*;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        solver.solve(in.nextInt(), in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            for (int t = 0; t < testNumber; t++) {
                int n = in.nextInt();
                int[] a = new int[n];
                for (int i = 0; i < a.length; i++) {
                    a[i] = in.nextInt();
                }
                out.println(new Solution().solve(a));
            }
        }

        public void duiPai() {
            Random random = new Random();
            for (int t = 0; t < 100; t++) {
                int n = random.nextInt(10) + 5;
                int[] a = genArr(n, 1, 9);
                System.out.println(Arrays.toString(a));
            }
        }

        public int[] genArr(int n, int l, int r) {
            int[] arr = new int[n];
            Random random = new Random();
            for (int i = 0; i < n; i++) {
                arr[i] = random.nextInt(r - l + 1) + l;
            }
            return arr;
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

class Solution {
    public int solve(int[] a) {
        int n = a.length;
        int[] index = new int[n + 5];
        boolean[] vis = new boolean[n];
        Arrays.fill(index, -1);
        int[] pre = new int[n];
        for (int i = 0; i < n; i++) {
            pre[i] = index[a[i]];
            index[a[i]] = i;
        }
        LazySegmentTree st = new LazySegmentTree(new int[n]);
        int ans = 0;
        int max = -1;
        for (int i = 0; i < n; i++) {
            int p = pre[i];
            st.update(i, i, p);
            if (p <= max || vis[p]) {
                st.update(i, i, -1);
                continue;
            }
            st.update(p, p, p);
            int j = 0;
            int m = max;
            while (p > max) {
                int t = st.query(p + 1, i - 1);
                if (t >= p) {
                    break;
                }
                p = t;
                j++;
                if (j == 3) {
                    m = t;
                }
            }
            if (p <= max) {
                max = Math.max(max, m);
                continue;
            }
            vis[i] = true;
            st.update(i, i, -1);
            ans++;
        }
        return ans;
    }
}

class LazySegmentTree {
    private final int[] arr;
    private final int n;
    private final int[] tree;
    private final int[] lazy;
    private final boolean[] vis;

    public LazySegmentTree(int[] arr) {
        this.arr = arr;
        this.n = arr.length;
        tree = new int[4 * n];
        lazy = new int[4 * n];
        vis = new boolean[4 * n];
        build(1, 0, n - 1);
    }

    public void update(int i, int j, int v) {
        update(1, 0, n - 1, i, j, v);
    }

    public int query(int i, int j) {
        return query(1, 0, n - 1, i, j);
    }

    private void build(int p, int l, int r) {
        if (l == r) {
            tree[p] = arr[l];
            return;
        }
        int mid = (l + r) / 2;
        build(p * 2, l, mid);
        build(p * 2 + 1, mid + 1, r);
        pushUp(p);
    }

    private void pushUp(int p) {
        tree[p] = Math.min(tree[p * 2], tree[p * 2 + 1]);
    }

    private void pushDown(int p, int l, int r) {
        if (vis[p]) {
            tree[p * 2] = Math.min(tree[p * 2], lazy[p]);
            tree[p * 2 + 1] = Math.min(tree[p * 2 + 1], lazy[p]);
            lazy[p * 2] = lazy[p];
            lazy[p * 2 + 1] = lazy[p];
            vis[p] = false;
        }
    }

    private void update(int p, int l, int r, int i, int j, int v) {
        if (i <= l && j >= r) {
            tree[p] = v;
            lazy[p] = v;
            vis[p] = true;
            return;
        }
        pushDown(p, l, r);
        int mid = (l + r) / 2;
        if (i <= mid) {
            update(p * 2, l, mid, i, j, v);
        }
        if (j > mid) {
            update(p * 2 + 1, mid + 1, r, i, j, v);
        }
        pushUp(p);
    }

    private int query(int p, int l, int r, int i, int j) {
        if (i <= l && j >= r) {
            return tree[p];
        }
        pushDown(p, l, r);
        int mid = (l + r) / 2;
        int ans = Integer.MAX_VALUE / 2;
        if (i <= mid) {
            ans = Math.min(ans, query(p * 2, l, mid, i, j));
        }
        if (j > mid) {
            ans = Math.min(ans, query(p * 2 + 1, mid + 1, r, i, j));
        }
        return ans;
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the given buggy code, we need to focus on edge cases and scenarios that are likely to cause the algorithm to fail. Here are the steps to think through this:

1. **Understand the Bug**: The buggy code seems to have issues with handling subarrays where elements repeat in a way that makes it difficult to determine the correct number of operations needed to make all subarrays unique.

2. **Identify Edge Cases**:
   - **All Elements Are the Same**: This is a common edge case that can expose issues in the algorithm.
   - **Repeating Elements in Specific Patterns**: Patterns where elements repeat in a way that the algorithm might miscount the number of operations.
   - **Small Arrays**: Small arrays can help in quickly verifying the correctness of the algorithm.

3. **Generate the Test Input**:
   - For the first test case, we can use an array where all elements are the same. This should require a significant number of operations to make all subarrays unique.
   - For the second test case, we can use an array with a repeating pattern that might be tricky for the algorithm to handle.
   - For the third test case, we can use a small array with a mix of unique and repeating elements.

Based on these considerations, here is the test input:

```plaintext
3
5
1 1 1 1 1
7
1 2 2 1 2 2 1
4
2 1 2 1
```

Explanation:
1. **Test Case 1**: All elements are the same (1, 1, 1, 1, 1). The expected output is 4, as we need to change 4 elements to make all subarrays unique.
2. **Test Case 2**: Repeating elements in a pattern (1, 2, 2, 1, 2, 2, 1). The expected output is 3, as we need to change 3 elements to make all subarrays unique.
3. **Test Case 3**: A small array with a mix of unique and repeating elements (2, 1, 2, 1). The expected output is 1, as we need to change 1 element to make all subarrays unique.

This test input should help in exposing the bug in the given buggy code.