/*#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>

int n = 0;
int min_namber = 101;

std::stack<int>  stop_stack;
std::vector<int> input_stack, output_stack;

int main()
{
	int index = 0;

	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		int input;
		std::cin >> input;
		input_stack.push_back(input);

		if (input_stack[i] < min_namber)
		{
			min_namber = input_stack[i];
			index = i + 1;
		}
	}

	std::reverse(input_stack.begin(), input_stack.end());

	for (int i = 0; i < index; i++)
	{
		stop_stack.push(input_stack.back());
		//std::cout << input_stack.back() << std::endl;
		input_stack.pop_back();
	}

	if (!stop_stack.empty())
	{
		output_stack.push_back(stop_stack.top());
		stop_stack.pop();
	}

	while (!input_stack.empty()) {
		if (!stop_stack.empty())
		{
			if (stop_stack.top() < input_stack.back())
			{
				output_stack.push_back(stop_stack.top());
				stop_stack.pop();
			}
			else {
				stop_stack.push(input_stack.back());
				input_stack.pop_back();
			}
		}
		else {
			stop_stack.push(input_stack.back());
			input_stack.pop_back();
		}
	} 

	//stop_stack.pop();

	while (stop_stack.size() > 0) {
		output_stack.push_back(stop_stack.top());
		stop_stack.pop();
	}

	bool isTrue = true;

	int sizeOut = output_stack.size();
	for (int i = 0; i < sizeOut - 1; i++)
	{
		if (i + 1 <= sizeOut)
			if (output_stack[i] > output_stack[i + 1])
				isTrue = false;
	}

	if (isTrue == true)
		std::cout << "YES" << std::endl;
	else
		std::cout << "NO" << std::endl;

	system("pause");

	return 0;
}*/

/*#include <iostream>
#include <fstream>

const int size_x = 9;
const int size_y = 10;

std::ifstream open_file("D:/������ � �������/10 �����/10 �/�������� ������/C++/VectorAndStack/input.txt");

bool input_mass[size_x][size_y];
int output_mass[size_x][size_y];

void TestCell(int x, int y)
{
	if (input_mass[x][y] == true)
	{
		if (input_mass[x - 1][y - 1]) output_mass[x][y]++;
		//if (input_mass[x][y - 1])	  output_mass[x][y]--;
		if (input_mass[x + 1][y - 1]) output_mass[x][y]++;
		//if (input_mass[x - 1][y])	  output_mass[x][y]--;
		if (input_mass[x][y])		  output_mass[x][y]++;
		//if (input_mass[x + 1][y])	  output_mass[x][y]--;
		if (input_mass[x - 1][y + 1]) output_mass[x][y]++;
		//if (input_mass[x][y + 1])	  output_mass[x][y]--;
		if (input_mass[x + 1][y + 1]) output_mass[x][y]++;

	} else output_mass[x][y] = input_mass[x][y];
}

int main()
{
	for (int y = 0; y < size_y; y++)
		for (int x = 0; x < size_x; x++)
		{
			std::string input;
			open_file >> input;
			if (input == "1")
				input_mass[x][y] = true;
			else
				input_mass[x][y] = false;
		}

	for (int y = 0; y < size_y; y++)
		for (int x = 0; x < size_x; x++)
		{
			output_mass[x][y] = input_mass[x][y];
		}

	for (int y = 1; y < size_y - 1; y++)
		for (int x = 1; x < size_x - 1; x++)
		{
			TestCell(x, y);
		}

	for (int y = 0; y < size_y; y++)
	{
		for (int x = 0; x < size_x; x++)
		{
			std::cout << output_mass[x][y] << " ";
		}
		std::cout << std::endl;
	}

	system("pause");

	return NULL;
}*/

/*#include <iostream>
#include <vector>

int n = 0;
std::vector<int> mass;
std::vector<int> distances;

void getDistance()
{
	for (int i = 0; i < n; i++)
	{
		int distance = 0;
		if (i - 1 >= 0)
			distance += mass[i] - mass[i - 1];
		if (i + 1 < n)
			distance += mass[i] - mass[i + 1];
		distances.push_back(distance);
	}
}

bool SortMin()
{
	for (int i = 0; i < n - 1; i++)
	{
		if (mass[i] > mass[i + 1])
		{
			int buff = mass[i];
			mass[i] = mass[i + 1];
			mass[i + 1] = buff;
			SortMin();
		}
	}

	return false;
}

int main()
{
	std::cin >> n;
	//std::cout << std::endl;
	for (int i = 0; i < n; i++)
	{
		int input = 0;
		std::cin >> input;
		mass.push_back(input);
	}

	SortMin();
	getDistance();

	int dis = 0;

	for (int i = 0; i < n; i++)
		if (distances[i] > 0) dis += distances[i];
		//std::cout << distances[i] << " ";
	std::cout << dis << std::endl;

	system("pause");
	return NULL;
}*/

/*#include <iostream>
#include <vector>

int n;
int massa;

std::vector<int> mass_mass;
std::vector<int> mass_cout;
bool outmass[100][100];

int GetMass(int line_size, bool mass[])
{
	int sum = 0;

	for (int i = 1; i <= line_size; i++)
	{
		if (mass[line_size - i] == true)
			sum += mass_mass[line_size - i];
	}

	return sum;
}

int GetCout(int line_size, bool mass[])
{
	int sum = 0;

	for (int i = 1; i <= line_size; i++)
	{
		if (mass[line_size - i] == true)
			sum += mass_cout[line_size - i];
	}

	return sum;
}

int main()
{
	std::cin >> n >> massa;

	for (int i = 0; i < n; i++)
	{
		int mass, cout;
		std::cin >> mass >> cout;

		mass_mass.push_back(mass);
		mass_cout.push_back(cout);
	}

	for (int i = 1; i <= massa; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (mass_mass[j] <= i)
			{
				for (int iter = 0; iter < j; iter++)
				{
					if (outmass[i][iter] == true)
						if (mass_cout[iter] > mass_cout[j])
						{
							std::cout << "M ";
						}
				}

				if (GetMass(j, outmass[i]) + mass_mass[j] <= massa)
				{
					outmass[i][j] = true;
				}
				else {
				}
			}

			std::cout << outmass[i][j] << " ";
		}
		std::cout << i << std::endl;
	}

	system("pause");
	return NULL;
}*/

/*#include <iostream>
#include <vector>

int t = 0;
std::vector<unsigned long long> outs;

int main()
{
	std::cin >> t;

	for (int i = 0; i < t; i++)
	{
		unsigned long long n, m, x;
		std::cin >> n >> m >> x;

		unsigned long long new_y = (x - 1) % n;
		unsigned long long new_x = (x - 1 - new_y) / n;

		unsigned long long out = new_y * m + new_x + 1;

		outs.push_back(out);
	}

	for (int i = 0; i < outs.size(); i++)
	{
		std::cout << outs[i] << std::endl;
	}

	//system("pause");
	return NULL;
}*/

#include <iostream>
#include <vector>

int t = 0;
int old = 0;
std::vector<int> output;

int main()
{
	std::cin >> t;
	for (int i = 0; i < t; i++)
	{
		int n = 0;
		std::cin >> n;

		int m = 0;
		bool Inv = true;

		for (int j = 0; j < n; j++)
		{
			old = m;
			std::cin >> m;

			if (j > 0 && output.size() < i + 1)
			{
				if (m != old)
				{
					if (Inv == false)
					{
						output.push_back(j - 1);
					}
					else {
						//Inv = false;
						if (j > 1)
						{
							if (j + 1 >= n)
							{
								output.push_back(j);
								Inv = false;
							}
							else
								Inv = false;
						}
						else {
							Inv = false;
						}
					}
					//
				}
				else {
					if (Inv == false)
						output.push_back(j - 2);
				}
			}
		}
	}

	for (int i = 0; i < output.size(); i++)
		std::cout << output[i] + 1 << std::endl;

	//system("pause");
	return NULL;
}