#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>exit
using namespace std;
//using namespace __gnu_pbds;
int i, j;
#define ll                          long long
#define mod                         1000000007
#define trailzero(n)               __builtin_ctz(n)
#define leadzero(n)                __builtin_clz(n)
#define pb(a)                      emplace_back(a)
#define setbits(n)                __builtin_popcount(n)
#define mp(a,b)                    make_pair(a,b)
#define lb                          lower_bound
#define ub                         upper_bound
#define pq                         priority_queue
#define gcd(a,b)                  __gcd(a,b)
#define sz(a)                      a.size()
#define ff                          first
#define ss                          second
#define all(v)                     v.begin(),v.end()
#define forr(i,a,n)                for(i=a;i<n;i++)
#define maxn                        1000000
#define endl                          "\n"
#define log2(x)                     log(x)/(double)log(2)
//ceil(log10(x)) No of digits in x
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > pbds;
//No does not have logn set bits leftmost set bit has logn position
//ceil(x/n) is same as (x+n-1)/n
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << endl;
    //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
//seive
ll spf[maxn + 2];
vector<ll>primes;
void seive()
{   ll i, j;
    ll prime[maxn];
    for (i = 1; i < maxn; i++)
    {
        prime[maxn] = 1;
    }

    for (i = 4; i < maxn; i += 2)
    {
        prime[i] = 0;
    }

    for (i = 3; i * i < maxn; i += 2)
    {
        if (prime[i])
        {
            for (j = i * i; j < maxn; j += i)
            {
                prime[j] = 0;
            }
        }
    }
    for (i = 2; i < maxn; i++)
    {
        if (prime[i])
        {
            primes.pb(i);
        }
    }


}

ll factor(ll x)
{   ll ans = 1;

    ll i;
    for (i = 0; i < sz(primes) and primes[i]*primes[i] <= x; i++)
    {
        if (x % primes[i] == 0)
        {
            ll cnt = 0;
            while (x % primes[i] == 0)
            {
                cnt++;
                x /= primes[i];
            }
            if (cnt & 1)
            {
                ans *= primes[i];
            }
        }
    }
    if (x != 1)
    {
        ans *= x;
    }
    return ans;
}
/*
int partition(int a[], int s, int e)
{
    int l = s - 1;
    int part = a[e];
    int i;
    for (i = s; i < e; i++)
    {
        if (a[i] <= part)
        {
            l++;
            swap(a[l], a[i]);
        }
    }
    swap(a[l + 1], a[e]);
    return l + 1;
}
void quickSort(int a[], int s, int e)
{
    if (s >= e)
        return;

    int mid = partition(a, s, e);
    quickSort(a, s, mid - 1);
    quickSort(a, mid + 1, e);
    //merge(a, s, e);
}
void bubbleSort(int a[], int n)
{
    int i;
    quickSort(a, 0, n - 1);
    for (i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
}

void sort012(int a[], int n)
{
    int l = 0;
    int m = 0;
    int r = n - 1;
    while (m <= r)
    {
        if (a[m] == 0)
        {
            swap(a[l++], a[m++]);
        }
        else if (a[m] == 1)
        {
            m++;
        }
        else
        {
            swap(a[m], a[r--]);
        }


    }
    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
}
/*bool iscyclicdfs(vector<vector<int>>&adj, int node, int stack[])
{

    stack[node] = 1;
    for (auto i : adj[node])
    {
        if ((stack[i] == 1) or (stack[i] == -1 and iscyclicdfs(adj, i, stack)))
        {
            return true;
        }
    }
    stack[i] = 2;
    return false;


}
void dfscycle(vector<vector<ll>>adj)
{
    int vis[n];
    memset(vis, -1, sizeof vis);
    return dfs(adj, 0, vis);


}*/

/*bool bipartite(vector<vector<ll>>&adj, int color[n], int curcolor)
{
    color[i] = curcolor;
    for (auto i : adj[node])
    {
        if (color[i] == curcolor)
            return false;
        else if (color[i] == -1)
        {
            bipartite(adj, color, curcolor ^ 1);
        }

    }
    return true;


}*/

/*void merge2(vector<int>a, vector<int>b)
{
    int dist[n][m];
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            dist[i][j] = graph[i][j];
        }
    }
    for (k = 0; k < n; k++)
    {
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < n; j++)
            {
                if (dist[i][k] + dist[k][j] < dist[i][j])
                {
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }



}
class dsu {
public:
    vector<int>sz, par;
    int n;
    dsu(int v)
    {
        n = v;
        par.resize(n);
        par.resize(v);

        for (i = 0; i < n; i++) {
            par[i] = i;
            sz[i] = 1;
        }
    }
    int find(int x)
    {   //time taking step
        if (par[x] == x)return x;
        return par[x] = find(par[x]);
    }

    void unionn(int x, int y)
    {
        int spa = find(x);
        int spb = find(y);
        if (spa != spb)
        {
            sz[spb] += sz[spa];
            par[spa] = spb;
            sz[spa] = 0;
            n--;
        }
    }
    void checkcycle(int u,int v)
    {
        int spa = find(u);
        int spb = find(v);
        if(spa==spb)
            return true;
        else
        {
            unionn(u,v);
            return false;
        }
    }
};
bool cmp(vector<int>a,vector<int>b)
return a[2]<b[2];
void kruskal(vector<int>edge[],int n,int m)
{//n->no of vertices;

dsu d(n);

sort(edge,edge+m,cmp);

ll minwt=0;
for(i=0;i<m;i++)
{
  int src=edge[i][0];
  int dest=edge[i][1];
  int wt=edge[i][2];
  if(d.cycle(src,dest))
  {
    continue;
  }
  else
  {
    ans+=wt;

  }



}
void dfs(int node,bool visited[],stack<int>&s)
{
    visited[node]=1;
    for(auto i:adj[node])
    {
        if(!visited[i])
            dfs(i,visited,s);
    }
    s.push(node);
}
void printscc(int node,bool visited[])
{
    cout<<node<<" ";
    visited[node]=1;
    for(auto i:reversed[node])
    {
        if(!visited[i])
        {
            printscc(i,visited);
        }
    }
}
void kosaraju(vector<vector<int>>adj)
{ int n=adj.size();
  bool visited[n];
  memset(visited,0,sizeof visited);
  stack<int>s;
  for(i=0;i<n;i++)
  {
    if(!visited[i])
    {
        dfs(i,visited,s);
    }
  }

 //generate reversed graph

  vector<vector<int>>reversed;
  for(i=0;i<n;i++)
  {
    for(auto j:adj[i])
    {
        reversed[j].pb(i);
    }
  }



  //print scc
  memset(visited,0,sizeof visited)
  while(!s.empty())
  {
    int top=s.top();
    s.pop();
    if(!visited[top])
    {
        printscc(top);
    }
  }











}











}
int ans=0;
int maxsumpath(node*root)
{
 if(root==NULL)
    return 0;
int left=maxsumpath(root->left);
int right=maxsumpath(root->right);
int op1=root->data;
int op2=left+root->data;
int op3=right+root->data;
int op4=left+right+root->data;
ans=max(ans,max(op1,max(op2,max(op3,op4))));

return max(op1,max(op2,op3));



}
void runningMedian()
{
    priority_queue<double,vector<double>>mx;
    priority_queue<double,vector<double>,greater<double>>mn;
    int x;
    cin>>x;
    double curmed=x;
    vector<double>ans;
    ans.pb(x);
    mx.pb(x);
    for(i=0;i<n;i++)
    {
        int x=a[i];
        if(sz(mx)>sz(mn))
        {
            if(x<curmed)
            {
              int top=mx.top();
              mx.pop();
              mn.push(top);
              mx.push(x);
            }
            else
            {
                mn.push(x);
            }
            curmed=(mx.top()+mn.top())/2.0;
            cout<<curmed<<" ";
        }
        else if(sz(mx)<sz(mn))
        {

            if(x>curmed)
            {
              int top=mn.top();
              mn.pop();
              mx.push(top);
              mn.push(x);
            }
            else
            {
                mx.push(x);
            }
            curmed=(mx.top()+mn.top())/2.0;
            cout<<curmed<<" ";
        }
        else
        {
            if(x<curmed)
            {
                mx.push(x);
            }
            else
            {
                mn.push(x);
            }
            curmed=(mx.top()+mn.top())/2.0;
        }
    }


}

bool issafe(int mat[1000][],int row,int col)
{
    if(row>=n or col>=n)
        return false;

   for(i=0;i<col;i++)
   {
    if(mat[row][i])return false;
   }

   for(i=row-1,j=col-1;i>=0 and j>=0;i--,j--)
   {
     if(mat[i][j])return false;
   }
   for(i=row+1,j=col-1;i<n and j>=0;j--)
   {
      if(mat[i][j])return false;
   }
   return true;

}
void nqueen(int a[],int n,int i)
{
if(i>=n){//print array
    return;}


for(j=i;j<n;j++)
{
    swap(a[i],a[j]);
    permute(a,n,i+1);
    swap(a[i],a[j]);
}

int knapsack(int we[],int cost[],int n,int w)
{
   for(i=0;i<=n;i++)
   {
    for(j=0;j<=w;j++)
    {if(i==0 or j==0)
       dp[i][j]=0;
       else
       {
        if(we[i-1]>j)
        {
           dp[i][j]=dp[i-1][j];
        }
        else
        {
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-we[i-1]]+cost[i-1])
        }
       }
    }
   }


}
node*monvalue(node*root)
{
    if(root->left==NULL and root->right==NULL)
        return root;
    return monvalue(root->left);
}
node* deletbst(node*root,int key)
{
    if(root==NULL)
        return NULL;

   if(key<root->data)
   {
    deletbst(root->left,key);
   }
   else if(key>root->data)
   {
    deletbst(root->right,key);
   }
   else
   {
    if((root->left==NULL) and (root->right==NULL))
    { delet(root);
        return NULL;

    }
    else if(root->left and root->right)
    {
        node*inorder=monvalue(root->right);
        swap(root->data,inorder->data);
        delete(inorder);
        return root;

    }
    else
    {
        if(root->left)
        {node*temp=root->left;
            delete(root);
            return temp;
        }
        else{
            node*temp=root->right;
            delete(root);
            return temp;
        }
    }



   }



}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll i, j, k, n, l, m, t;
    cin >> t;

    //t = 1;

    while (t--)
    {
        cin >> n;
        ll a[n];
        ll res = 0;
        map<ll, ll>ma;
        for (i = 0; i < n; i++)
        {
            cin >> a[i];

            ma[a[i]] = i;
        }

        if (a[0] == a[n - 1])
        {
            for (i = 0; i < n; i++)
            {
                if (a[i] != a[0])
                {
                    cout << i + 1 << endl;
                    break;
                }
            }
        }
        else
        {
            if (a[1] == a[0])
            {
                cout << n << endl;
            }
            else
            {
                cout << 1 << endl;
            }
        }
    }

}

