An even sequence has the following property: each maximal contiguous subsequence which contains only equal integers (i.e. the same integer repeated a number of times) has an even length. In particular, the empty sequence is even. A subsequence is maximal if it is not contained in a larger contiguous subsequence which contains only equal integers.
Chef was given an integer sequence $A_1, A_2, \ldots, A_N$ by his friend Mr. Z. He may perform the following operation any number of times: either delete an element of the current sequence (if it is non-empty) or insert an integer anywhere in the current sequence (possibly at the beginning or at the end).
Find the minimum number of operations needed to make the sequence even.
-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$.
- The second line contains $N$ space-separated integers $A_1, A_2, \ldots, A_N$.
-----Output-----
For each test case, print a single line containing one integer — the minimum number of operations.
-----Constraints-----
- $1 \leq T \leq 10$
- $1 \leq N \leq 2 \cdot 10^5$
- $1 \leq A_i \leq N$ for each valid $i$
- the sum of $N$ over all test cases does not exceed $2 \cdot 10^6$
-----Subtasks-----
Subtask #1 (10 points): $N \leq 18$
Subtask #2 (10 points): $A_i \leq A_{i+1}$ for each valid $i$
Subtask #3 (20 points): $N \leq 3,000$
Subtask #4 (20 points): $A_i \leq 26$ for each valid $i$
Subtask #5 (40 points): original constraints
-----Example Input-----
2
4
1 1 2 1
11
2 2 2 10 2 10 1 1 5 3 5
-----Example Output-----
2
3
-----Explanation-----
Example case 1: Here are two ways to make the sequence even using $2$ operations:
- Delete the first element $1$ and the only element $2$, resulting in a sequence $(1, 1)$, which is even.
- Delete the last element $1$ and insert $2$ at the end, resulting in a sequence $(1,1,2,2)$, which is even.
It can be proved that one operation is not enough to make the initial sequence even.
"""
Code Chef :: December 2020 Lunchtime :: Even Sequence Problem Code: EVSTR
https://www.codechef.com/LTIME91B/problems/EVSTR
"""
import sys
from math import inf


def solve(i, prev, cnt, ops, A):
 # Base Case
 if i >= len(A):
  if cnt % 2 == 0:
   return ops
  else:
   return inf

 result = inf
 if A[i] == prev:
  result = min(result, solve(i + 1, prev, cnt + 1, ops, A))
 else:
  if cnt % 2:
   # If cnt is odd, we can
   # (1) Fix it and add current.  It will cost on op to fix.
   result = min(result, solve(i + 1, A[i], 1, ops + 1, A))
   # (2) Not fix it and delete current.
   result = min(result, solve(i + 1, prev, cnt, ops + 1, A))
  else:
   # If cnt is even, we can
   # (1) Delete current
   result = min(result, solve(i + 1, prev, cnt, ops + 1, A))
   # (2) Add current
   result = min(result, solve(i + 1, A[i], 1, ops, A))
 return result


def main():
 """Main program."""
 sys.setrecursionlimit(pow(10, 9))
 test_cases = int(sys.stdin.readline())
 for _ in range(test_cases):
  N = int(sys.stdin.readline())
  A = [int(i) for i in sys.stdin.readline().split()]
  soln = solve(0, 0, 0, 0, A)
  print(soln)


def __starting_point():
 main()

__starting_point()
"""
Code Chef :: December 2020 Lunchtime :: Even Sequence Problem Code: EVSTR
https://www.codechef.com/LTIME91B/problems/EVSTR
"""
import sys
from math import inf


def solve(i, prev, cnt, ops, A):
 # Base Case
 if i >= len(A):
  if cnt % 2 == 0:
   return ops
  else:
   return inf

 result = inf
 if A[i] == prev:
  result = min(result, solve(i + 1, prev, cnt + 1, ops, A))
 else:
  if cnt % 2:
   # If cnt is odd, we can
   # (1) Fix it and add current.  It will cost on op to fix.
   result = min(result, solve(i + 1, A[i], 1, ops + 1, A))
   # (2) Not fix it and delete current.
   result = min(result, solve(i + 1, prev, cnt, ops + 1, A))
  else:
   # If cnt is even, we can
   # (1) Delete current
   result = min(result, solve(i + 1, prev, cnt, ops + 1, A))
   # (2) Add current
   result = min(result, solve(i + 1, A[i], 1, ops, A))
 return result


def main():
 """Main program."""
 sys.setrecursionlimit(pow(10, 9))
 test_cases = int(sys.stdin.readline())
 for _ in range(test_cases):
  N = int(sys.stdin.readline())
  A = [int(i) for i in sys.stdin.readline().split()]
  soln = solve(0, 0, 0, 0, A)
  print(soln)


def __starting_point():
 main()

__starting_point()