#include<iostream>
using namespace std;

//宣告
long long int k[500001] = { 0 };

int main() {

	int city;
	cin >> city;

	//輸入
	for (int i = 1; i <= city; i++) {
		int tmp = 0;
		cin >> tmp;
		if (tmp - i >= 0) {
			k[tmp - i] += tmp;
		}
	}
	int max = 0;
	for (int i = 0; i <= 500001; i++) {
		if (k[i] > max) max = k[i];
	}
	cout << max << endl;
	return 0;
}


#include<iostream>
using namespace std;

//宣告
int k[510000] = { 0 };

int main() {

	int city;
	cin >> city;

	//輸入
	for (int i = 1; i <= city; i++) {
		int tmp = 0;
		cin >> tmp;
		if (tmp - i >= 0) {
			k[tmp - i] += tmp;
		}
	}

	int max = 0;
	for (int i = 0; i <= 400000; i++) {
		if (k[i] > max) max = k[i];
	}

	cout << max << endl;

	return 0;
}


#include<iostream>
using namespace std;

int main() {

	int city;
	while (cin >> city) {
		//宣告
		int beauty[210000] = { 0 };
		bool took[210000] = { 0 };
		//輸入
		for (int i = 1; i <= city; i++) {
			cin >> beauty[i];
		}

		long long int sum = 0;
		for (int i = 1; i <= city; i++) {
			if (took[i] != 1) {
				took[i] = 1;
				long long int tmp = beauty[i];
				for (int j = i + 1; j <= city; j++) {
					if (took[j] != 1 && j - i == beauty[j] - beauty[i]) {
						tmp += beauty[j];
						took[j] = 1;
					}
				}
				if (tmp > sum) sum = tmp;
			}
		}

		cout << sum << endl;
	}

	return 0;
}


#include<iostream>
using namespace std;

int main() {

	int city;
	while (cin >> city) {
		//宣告
		int beauty[210000] = { 0 };
		bool took[210000] = { 0 };
		//輸入
		for (int i = 1; i <= city; i++) {
			cin >> beauty[i];
		}

		long long int sum = 0;
		int cnt = 0;
		for (int i = 1; i <= city && cnt < 3; i++) {
			if (took[i] != 1) {
				took[i] = 1;
				long long int tmp = beauty[i];
				for (int j = i + 1; j <= city; j++) {
					if (took[j] != 1 && j - i == beauty[j] - beauty[i]) {
						tmp += beauty[j];
						took[j] = 1;
					}
				}
				if (tmp > sum) {
					sum = tmp;
					cnt++;
				}
			}
		}

		cout << sum << endl;
	}

	return 0;
}


#include<iostream>
using namespace std;

//宣告
long long int k[500001] = { 0 };
long long int K[500001] = { 0 };

int main() {

	int city;
	cin >> city;

	//輸入
	for (int i = 1; i <= city; i++) {
		int tmp = 0;
		cin >> tmp;
		if (tmp - i >= 0) {
			k[tmp - i] += tmp;
		}
		else {
			K[i - tmp] += tmp;
		}
	}
	long long int max = 0;
	for (int i = 0; i <= 500000; i++) {
		if (k[i] > max) max = k[i];
		if (K[i] > max) max = K[i];
	}
	cout << max << endl;
	return 0;
}


#include<iostream>
using namespace std;

int main() {

	int city;
	while (cin >> city) {
		//宣告
		int beauty[210000] = { 0 };
		bool took[210000] = { 0 };
		//輸入
		for (int i = 1; i <= city; i++) {
			cin >> beauty[i];
		}

		long long int sum = 0;
		int cnt = 0;
		for (int i = 1; i <= city; i++) {
			if (took[i] != 1) {
				took[i] = 1;
				long long int tmp = beauty[i];
				for (int j = i + 1; j <= city; j++) {
					if (took[j] != 1 && j - i == beauty[j] - beauty[i]) {
						tmp += beauty[j];
						took[j] = 1;
					}
				}
				if (tmp > sum) {
					sum = tmp;
					cnt++;
				}
			}
		}

		cout << sum << endl;
	}

	return 0;
}


#include<iostream>
using namespace std;

//宣告
int beauty[210000] = { 0 };
bool took[210000] = { 0 };

int main() {

	int city;
	cin >> city;

	//輸入
	for (int i = 1; i <= city; i++) {
		cin >> beauty[i];
	}

	long long int sum = 0;
	int cnt = 0;
	for (int i = 1; i <= city && cnt < 3; i++) {
		if (took[i] != 1) {
			took[i] = 1;
			long long int tmp = beauty[i];
			for (int j = i + 1; j <= city; j++) {
				if (took[j] != 1 && j - i == beauty[j] - beauty[i]) {
					tmp += beauty[j];
					took[j] = 1;
				}
			}
			if (tmp > sum) {
				sum = tmp;
				cnt++;
			}
		}
	}

	cout << sum << endl;

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


#include<iostream>
using namespace std;

int main() {

	int city;
	while (cin >> city) {
		//宣告
		int beauty[110000] = { 0 };
		bool took[110000] = { 0 };
		//輸入
		for (int i = 1; i <= city; i++) {
			cin >> beauty[i];
		}

		int sum = 0;
		for (int i = 1; i <= city && took[i] != 1; i++) {
			took[i] = 1;
			int tmp = beauty[i];
			for (int j = i + 1; j <= city; j++) {
				if (j - i == beauty[j] - beauty[i]) {
					tmp += beauty[j];
				}
			}
			if (tmp > sum) sum = tmp;
		}

		cout << sum << endl;
	}

	return 0;
}


#include<iostream>
using namespace std;

int main() {

	int city;
	while (cin >> city) {
		//宣告
		int beauty[110000] = { 0 };
		bool took[110000] = { 0 };
		//輸入
		for (int i = 1; i <= city; i++) {
			cin >> beauty[i];
		}

		int sum = 0;
		for (int i = 1; i <= city; i++) {
			int tmp = beauty[i];
			for (int j = i + 1; j <= city; j++) {
				if (j - i == beauty[j] - beauty[i]) {
					tmp += beauty[j];
				}
			}
			if (tmp > sum) sum = tmp;
		}

		cout << sum << endl;
	}

	return 0;
}


#include<iostream>
using namespace std;

//宣告
long long int k[500001] = { 0 };

int main() {

	int city;
	cin >> city;

	//輸入
	for (int i = 1; i <= city; i++) {
		int tmp = 0;
		cin >> tmp;
		if (tmp - i >= 0) {
			k[tmp - i] += tmp;
		}
	}
	long long int max = 0;
	for (int i = 0; i <= 500000; i++) {
		if (k[i] > max) max = k[i];
	}
	cout << max << endl;
	return 0;
}


#include<iostream>
using namespace std;

int main() {

	int city;
	while (cin >> city) {
		//宣告
		int beauty[110000] = { 0 };
		bool took[110000] = { 0 };
		//輸入
		for (int i = 1; i <= city; i++) {
			cin >> beauty[i];
		}

		int sum = 0;
		for (int i = 1; i <= city; i++) {
			if (took[i] != 1) {
				took[i] = 1;
				int tmp = beauty[i];
				for (int j = i + 1; j <= city; j++) {
					if (j - i == beauty[j] - beauty[i]) {
						tmp += beauty[j];
						took[j] = 1;
					}
				}
				if (tmp > sum) sum = tmp;
			}
		}

		cout << sum << endl;
	}

	return 0;
}


#include<iostream>
using namespace std;

struct c {
	//y=x+k
	int scalar;//k
	long long int val;//數量
};

c arr[100000] = { 0 };

int main() {

	int city;
	cin >> city;

	for (int i = 1; i <= city; i++) {
		//輸入數字
		int tmp;
		cin >> tmp;
		//決定是否新增一條
		bool new_scalar = true;

		int j = 0;
		for (; arr[j].val != 0; j++) {
			if (arr[j].scalar == tmp - i) {
				new_scalar = false;
				arr[j].val += tmp;
			}
		}
		if (new_scalar == true) {
			arr[j].scalar = tmp - i;
			arr[j].val += tmp;
		}
	}

	long long int max = 0;
	for (int i = 0; arr[i].val != 0; i++) {
		if (arr[i].val > max)max = arr[i].val;
	}

	cout << max << endl;
//	system("pause");
	return 0;
}


#include<iostream>
using namespace std;

//宣告
long long int k[500001] = { 0 };

int main() {

	int city;
	cin >> city;

	//輸入
	for (int i = 1; i <= city; i++) {
		int tmp = 0;
		cin >> tmp;
		if (tmp - i >= 0) {
			k[tmp - i] += tmp;
		}
	}
	int max = 0;
	for (int i = 0; i <= 500000; i++) {
		if (k[i] > max) max = k[i];
	}
	cout << max << endl;
	return 0;
}


#include<iostream>
using namespace std;

//宣告
long long int k[500001] = { 0 };

int main() {

	int city;
	cin >> city;

	//輸入
	for (int i = 1; i <= city; i++) {
		int tmp = 0;
		cin >> tmp;
		if (tmp - i >= 0) {
			k[tmp - i] += tmp;
		}
	}

	int max = 0;
	for (int i = 0; i <= 400000; i++) {
		if (k[i] > max) max = k[i];
	}

	cout << max << endl;

	return 0;
}


#include<iostream>
using namespace std;

//宣告
int beauty[210000] = { 0 };

int main() {

	int city;
	cin >> city;

	//輸入
	for (int i = 1; i <= city; i++) {
		cin >> beauty[i];
	}

	long long int sum = 0;
	for (int i = 1; i <= city; i++) {
		long long int tmp = beauty[i];
		for (int j = i + 1; j <= city; j++) {
			if (j - i == beauty[j] - beauty[i]) {
				tmp += beauty[j];
			}
		}
		if (tmp > sum) {
			sum = tmp;
		}
	}

	cout << sum << endl;

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


#include<iostream>
using namespace std;

int main() {

	int city;
	while (cin >> city) {
		//宣告
		int beauty[110000] = { 0 };
		bool took[110000] = { 0 };
		//輸入
		for (int i = 1; i <= city; i++) {
			cin >> beauty[i];
		}

		int sum = 0;
		for (int i = 1; i <= city && took[i] != 1; i++) {
			took[i] = 1;
			int tmp = beauty[i];
			for (int j = i + 1; j <= city; j++) {
				if (j - i == beauty[j] - beauty[i]) {
					tmp += beauty[j];
					took[j] = 1;
				}
			}
			if (tmp > sum) sum = tmp;
		}

		cout << sum << endl;
	}

	return 0;
}


#include<iostream>
using namespace std;

int main() {

	int city;
	while (cin >> city) {
		//宣告
		int beauty[210000] = { 0 };
		bool took[210000] = { 0 };
		//輸入
		for (int i = 1; i <= city; i++) {
			cin >> beauty[i];
		}

		int sum = 0;
		for (int i = 1; i <= city; i++) {
			if (took[i] != 1) {
				took[i] = 1;
				int tmp = beauty[i];
				for (int j = i + 1; j <= city; j++) {
					if (j - i == beauty[j] - beauty[i] && took[j] != 1) {
						tmp += beauty[j];
						took[j] = 1;
					}
				}
				if (tmp > sum) sum = tmp;
			}
		}

		cout << sum << endl;
	}

	return 0;
}


#include<iostream>
#include<cstring>

using namespace std;

#define INF 1e10+5
#define MAXN 400005
#define MINN -105
typedef long long int LL;

int main()
{
    int n;
    int a[MAXN];
    int b;
    int ans=0;
    memset(a,0,sizeof(a));
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>b;
        if(i>b)
        {
            ans=max(ans,b);
            continue;
        }
        else
        {
            a[b-i]+=b;
            ans=max(ans,a[b-i]);
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1000002;
typedef long long ll;
ll Ans,p[N];
int n,i,j,k,a,b;
int main(){
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&b);
        a=b-i+N/2;
        Ans=max(Ans,p[a]+=b);
    }
    printf("%lld",Ans);
}


#include<bits/stdc++.h>
#include<map>
using namespace std;
int a[500003],b[500003];
bool f[500003];
using namespace std;
map<int,int> M;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++) scanf("%d",&a[i]);
    for(int i=1; i<=n; i++)
    {
        map<int,int>::iterator m;
        m=M.find(a[i]-i);
        if(m!=M.end()) b[m->second]=i,f[i]=1,M.erase(m);
        M[a[i]-i]=i;
    }
    long long ans=0,now;
    int pos;
    for(int i=1; i<=n; i++) if(!f[i])
    {
        now=a[i],pos=i;
        while(b[pos]) pos=b[pos],now+=a[pos];
        if(now>ans) ans=now;
    }
    cout<<ans;
    return 0;
}


// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int last[600005];
ll ans[200005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    ll opt = 0;
    rep1(i, n) {
        int b; cin >> b;
        int r = b - i + 200000;
        ans[i] = ans[last[r]] + b;
        opt = max(opt, ans[i]);
        last[r] = i;
    }
    cout << opt << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+9,M=8e5+19,I=4e5+9;
int n,ans,maxn;
int a[N],b[M];

signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		maxn=max(maxn,a[i]);
		b[a[i]-i+I]+=a[i];
	}
	for(int i=1;i<=M;i++)
	{
		maxn=max(maxn,b[i]);
	}
	printf("%lld",maxn);
	return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int cnt[800005],n,x;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	FOR(i,1,n){
		cin>>x;
		cnt[x-i+400000]+=x;
	}
	int ans=0;
	FOR(i,0,800000)ans=max(ans,cnt[i]);
	cout<<ans<<'\n';
	RE 0;
}


//#include<>
#include<bits/stdc++.h>
#define int long
using namespace std;
int n;
int a[50000];
int dfs(int i,int sb)
{
	if(i==n) return sb;
	int maxn=0;
	bool flag=false;
	for(int j=i+1;j<=n;j++)
	{
		if(j-i==a[j]-a[i])
		{
			flag=true;
			maxn=max( maxn , dfs(j,sb+a[j]) );
		}
	}
	if(!flag) return sb;
	return maxn;
}
signed main()
{
//  freopen(" ","r",stdin);
	cin>>n;
	if(n==1) {int oo;cin>>oo;cout<<oo;exit(0);	}
	for(int i=1;i<=n;i++)
	cin>>a[i];
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int t=dfs(i,a[i]);
		ans=max(ans,t);
	}
	cout<<ans;

    return 0;
}


# include <bits/stdc++.h>
# define rr register
# define int long long
const int N=500010,INF=0x3f3f3f3f;
int b[N];
int wz[N];
int f[N];
int n;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
signed main(void){
	n=read();
	for(rr int i=1;i<=n;++i){
		b[i]=read();
	}
	wz[b[1]]=b[1];
	f[1]=b[1];
	for(rr int i=2;i<=n;++i){
		f[i]=wz[b[i]-(i-1)]+b[i];
//		printf("%I64d %I64d\n",b[i]-(i-1),wz[b[i]-(i-1)]);
		wz[b[i]-(i-1)]=f[i];
//		printf("%I64d %I64d\n",b[i]-(i-1),wz[b[i]-(i-1)]);
	}
	int maxx=0;
	for(rr int i=1;i<=n;++i){
//		printf("%I64d ",f[i]);
		maxx=std::max(maxx,f[i]);
	}
	printf("%I64d",maxx);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[1000100],n;
int f[1000100];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int ans=0;
	for(int i=1;i<=n;i++)ans=max(ans,f[a[i]-i+n]+=a[i]);
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[1000100],n;
long long f[1000100];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	long long ans=0;a
	for(int i=1;i<=n;i++)ans=max(ans,f[a[i]-i+n]+=a[i]);
	cout<<ans;
	return 0;
}


#include <iostream>

using namespace std;

long long n , a[1000005] , f[1000005];

long long  ans = 0;

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n; i++)
		ans = max(ans , f[a[i] - i + n] += a[i]);
	cout << ans;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 2e5;
int f[N+1];
int c[N+1];
int main()
{
	int n;
	cin >> n;
	for(int i=1; i<=n; i++)
	{
		cin >> c[i];
	}
	int ans = 0;
	for(int i=1; i<=n; i++)
	{
		ans = max(ans, (f[c[i]-i]+=c[i]));
	}
	cout << ans << endl;
	return 0;
}


#include<map>
#include<list>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define il inline
#define ll long long
#define rl register ll
#define ri register int
#define rc register char
using namespace std;
il int read(){
	rc c=' ';
	ri v=0,x=1;
	while((c<'0')||(c>'9')){if(c=='-') x=-1;c=getchar();}
	while((c>='0')&&(c<='9')){v=(v<<1)+(v<<3)+(c^48);c=getchar();}
	return v*x;
}
il void write(rl x){
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10^48);
}
const int N=5e5+10;
int n,a[N];
ll ans,dp[N];
int main(){
	n=read();
	for(ri i=1;i<=n;i++){
		a[i]=read();
		dp[a[i]-i+n]+=a[i];
		ans=max(ans,dp[a[i]-i+n]);
	}
	write(ans);
	return ~~(0-0);
}


#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=6e5+8;
const int T=2e5+2;
int n,b[N],t[N];

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

struct Segment_Tree {
	#define mid ((l+r)>>1)
	#define lc(x) ((x)<<1)
	#define rc(x) ((x)<<1|1)
	ll sum[N<<2];
	void update(int x,int l,int r,int pos,int val) {
		if(l==r) {sum[x]+=val;return void();}
		(pos<=mid)?update(lc(x),l,mid,pos,val):update(rc(x),mid+1,r,pos,val);
		sum[x]=max(sum[lc(x)],sum[rc(x)]);
	}
}Tree;

int main() {
	IN(n);
	for(int i=1;i<=n;++i) IN(b[i]),t[i]=b[i]-i+T;
	for(int i=1;i<=n;++i) Tree.update(1,1,N-1,t[i],b[i]);
	printf("%lld\n",Tree.sum[1]);
	return 0;
}


#include <iostream>
using namespace std;

int Find (int tab[], int N){
    int sum_max=0;
    if (N==1) return tab[0];
    for(int i=0; i<N-1 ; i++){
       int sum = 0;
       int temp = i;
       sum = tab[temp];
        for(int j=i+1; j<N ; j++){
            if(j-temp == tab[j]-tab[temp]){
                sum+=tab[j];
                temp=j;
            }
        }
    if(sum > sum_max) sum_max=sum;
    }
    if (tab[N-1] > sum_max) return tab[N-1];
    return sum_max;
}

int main(){
int N;
cin >> N;
int tab[N];
for (int i=0; i<N; i++){
    cin >> tab[i];
}

cout << Find(tab, N);

}


#include <iostream>
using namespace std;

int Find (int tab[], int N){
    int sum_max=0;
    if (N==1) return tab[0];
    for(int i=0; i<N-1 ; i++){
       int sum = 0;
       int temp = i;
       sum = tab[temp];
        for(int j=i+1; j<N ; j++){
            if(j-temp == tab[j]-tab[temp]){
                sum+=tab[j];
                temp=j;
            }
        }
    if(sum > sum_max) sum_max=sum;
    }
    return sum_max;
}

int main(){
int N;
cin >> N;
int tab[N];
for (int i=0; i<N; i++){
    cin >> tab[i];
}

cout << Find(tab, N);

}


#include <iostream>
using namespace std;

int Find (int tab[], int N){
    int sum_max=0;
    if (N==1) return tab[0];
    int tab1[N]={0};
    for(int i=0; i<N-1 && tab1[i] != tab[i] ; i++){
       int sum = 0;
       int temp = i;
       tab1[temp]=tab[temp];
       sum = tab[temp];
        for(int j=i+1; j<N ; j++){
            if(j-temp == tab[j]-tab[temp]){
                sum+=tab[j];
                temp=j;
                tab1[j]=tab[j];
            }
        }
    if(sum > sum_max) sum_max=sum;
    }
    if (tab[N-1] > sum_max) return tab[N-1];
    return sum_max;
}

int main(){
int N;
cin >> N;
int tab[N];
for (int i=0; i<N; i++){
    cin >> tab[i];
}

cout << Find(tab, N);

}


#include <iostream>
#include <iomanip>
using namespace std;

void Find (double tab[], int N){
    double sum_max=0;
    if (N==1) cout << setprecision(15) << tab[0];
    return;
    double tab1[N]={0};
    for(int i=0; i<N-1; i++){
       if (tab1[i] != tab[i]){
       double sum = 0;
       int temp = i;
       tab1[temp]=tab[temp];
       sum = tab[temp];
        for(int j=i+1; j<N ; j++){
            if(j-temp == tab[j]-tab[temp]){
                sum+=tab[j];
                temp=j;
                tab1[j]=tab[j];
                //cout << sum << endl;
            }
        }
    //cout << sum;
    if(sum > sum_max) sum_max=sum;
    }
    }
    if (tab[N-1] > sum_max) cout << setprecision(15) << tab[N-1];
    cout <<setprecision(15) << sum_max;
}

int main(){
int N;
cin >> N;
double tab[N];
for (int i=0; i<N; i++){
    cin >> tab[i];
}

Find(tab, N);

}


#include <iostream>
#include <iomanip>
using namespace std;

void Find (double tab[], int N){
    double sum_max=0;
    if (N==1) cout << setprecision(15) << tab[0];
    else{
    double tab1[N]={0};
    for(int i=0; i<N-1; i++){
       if (tab1[i] != tab[i]){
       double sum = 0;
       int temp = i;
       tab1[temp]=tab[temp];
       sum = tab[temp];
        for(int j=i+1; j<N ; j++){
            if(j-temp == tab[j]-tab[temp]){
                sum+=tab[j];
                temp=j;
                tab1[j]=tab[j];
                //cout << sum << endl;
            }
        }
    //cout << sum;
    if(sum > sum_max) sum_max=sum;
    }
    }
    if (tab[N-1] > sum_max) cout << setprecision(15) << tab[N-1];
    else cout <<setprecision(15) << sum_max;
    }
}

int main(){
int N;
cin >> N;
double tab[N];
for (int i=0; i<N; i++){
    cin >> tab[i];
}

Find(tab, N);

}


#include <iostream>
using namespace std;

int k = 200000; // this is because b-i+k >= 0
long long tab[600001]; // 600000 is 400000 + maximal N
int b; // beautifulness
int main(){
    long long maks = 0;
    int N;
    cin >> N;
    for(int i = 0 ; i<N ; i++){
        cin >> b;
        tab[b-i+k]+=b;  //cities with the common b-i value are in the same tour
        if(tab[b-i+k] > maks) maks = tab[b-i+k];
    }
    cout << maks <<endl;
}


#include <iostream>
using namespace std;

int Find (int tab[], int N){
    int sum_max=0;
    if (N==1) return tab[0];
    int tab1[N]={0};
    for(int i=0; i<N-1; i++){
       if (tab1[i] != tab[i]){
       int sum = 0;
       int temp = i;
       tab1[temp]=tab[temp];
       sum = tab[temp];
        for(int j=i+1; j<N ; j++){
            if(j-temp == tab[j]-tab[temp]){
                sum+=tab[j];
                temp=j;
                tab1[j]=tab[j];
                //cout << sum << endl;
            }
        }
    if(sum > sum_max) sum_max=sum;
    }
    }
    if (tab[N-1] > sum_max) return tab[N-1];
    return sum_max;
}

int main(){
int N;
cin >> N;
int tab[N];
for (int i=0; i<N; i++){
    cin >> tab[i];
}

cout << Find(tab, N);

}


#include <iostream>
using namespace std;

int Find (int tab[], int N){
    int sum_max=0;
    if (N==1) return tab[0];
    int tab1[N]={0};
    for(int i=0; i<N-1; i++){
       if (tab1[i] != tab[i]){
       double sum = 0;
       int temp = i;
       tab1[temp]=tab[temp];
       sum = tab[temp];
        for(int j=i+1; j<N ; j++){
            if(j-temp == tab[j]-tab[temp]){
                sum+=tab[j];
                temp=j;
                tab1[j]=tab[j];
                //cout << sum << endl;
            }
        }
    //cout << sum;
    if(sum > sum_max) sum_max=sum;
    }
    }
    if (tab[N-1] > sum_max) return tab[N-1];
    return sum_max;
}

int main(){
int N;
cin >> N;
int tab[N];
for (int i=0; i<N; i++){
    cin >> tab[i];
}

cout << Find(tab, N);

}


#include <iostream>
using namespace std;

int Find (int tab[], int N){
    int sum_max=0;
    int sum;
    if (N==1) return tab[0];
    for(int i=0; i<N-1 ; i++){
       int temp = i;
       sum = tab[temp];
        for(int j=i+1; j<N ; j++){
            if(j-temp == tab[j]-tab[temp]){
                sum+=tab[j];
                temp=tab[j];
            }
        }
    if(sum > sum_max) sum_max=sum;
    }
    return sum_max;
}

int main(){
int N;
cin >> N;
int tab[N];
for (int i=0; i<N; i++){
    cin >> tab[i];
}

cout << Find(tab, N);

}


#include <iostream>
#include <iomanip>
using namespace std;

void Find (double tab[], int N){
    double sum_max=0;
    if (N==1) cout << setprecision(15) << tab[0];
    else{
    double tab1[N]={0};
    for(int i=0; i<N-1; i++){
       if (tab1[i] != tab[i]){
       double sum = 0;
       int temp = i;
       tab1[temp]=tab[temp];
       sum = tab[temp];
        for(int j=i+1; j<N ; j++){
            if(j-temp == tab[j]-tab[temp]){
                sum+=tab[j];
                temp=j;
                tab1[j]=tab[j];
                //cout << sum << endl;
            }
        }
    //cout << sum;
    if(sum > sum_max) sum_max=sum;
    }
    }
    if (tab[N-1] > sum_max) cout << setprecision(15) << tab[N-1];
    cout <<setprecision(15) << sum_max;
    }
}

int main(){
int N;
cin >> N;
double tab[N];
for (int i=0; i<N; i++){
    cin >> tab[i];
}

Find(tab, N);

}


#include <iostream>
using namespace std;

int Find (int tab[], int N){
    int sum_max=0;
    if (N==1) return tab[0];
    int tab1[N]={0};
    for(int i=0; i<N-1; i++){
       if (tab1[i] != tab[i]){
       double sum = 0;
       int temp = i;
       tab1[temp]=tab[temp];
       sum = tab[temp];
        for(int j=i+1; j<N ; j++){
            if(j-temp == tab[j]-tab[temp]){
                sum+=tab[j];
                temp=j;
                tab1[j]=tab[j];
                //cout << sum << endl;
            }
        }
    cout << sum;
    if(sum > sum_max) sum_max=sum;
    }
    }
    if (tab[N-1] > sum_max) return tab[N-1];
    return sum_max;
}

int main(){
int N;
cin >> N;
int tab[N];
for (int i=0; i<N; i++){
    cin >> tab[i];
}

cout << Find(tab, N);

}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
ll n,a,i,b;
map<ll,ll> m;
int main(){
    cin>>n;
    while(i++<n)
        cin>>b,m[b-i]+=b,a=max(a,m[b-i])
    cout<<a;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i ,a, n) for (long long int i=a;i<=n;i++)
#define pb  push_back
#define mp make_pair
#define fp first
#define sp second
#define be(v) v.begin(),v.end()
typedef long long ll;
typedef vector<ll> vi ;
typedef vector<pair<ll , ll > >  vpi ;
const int ma1=3e5+5;
string no="NO",yes="YES";
const unsigned int MOD = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[2*n+1];
        vi o;
        vi e;
        for(int i=1;i<=(2*n);i++)
        {
            cin>>a[i];
        }
        for(int i=1;i<=(2*n);i++)
        {
            if(a[i]%2==0)
                e.pb(i);
            else o.pb(i);
        }
        ll i=0,j=0,c=0;
        while(c<(n-1) && (i<o.size()-1))
        {
            if(i<(o.size()-1))
            {
                ll x=o[i];
                ll y=o[i+1];
            cout<<x<<" "<<y<<endl;
            i+=2;
            c++;
        }
        }
         while(c<(n-1) && (j<e.size()-1))
        {
            if(j<(e.size()-1))
            {
                ll x=e[j];
                ll y=e[j+1];
            cout<<x<<" "<<y<<endl;
            j+=2;
            c++;
            }
        }        o.clear();
        e.clear();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i ,a, n) for (long long int i=a;i<=n;i++)
#define pb  push_back
#define mp make_pair
#define fp first
#define sp second
#define be(v) v.begin(),v.end()
typedef long long ll;
typedef vector<ll> vi ;
typedef vector<pair<ll , ll > >  vpi ;
const int ma1=3e5+5;
string no="NO",yes="YES";
const unsigned int MOD = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[2*n+1];
        vi o;
        vi e;
        for(int i=1;i<=(2*n);i++)
        {
            cin>>a[i];
        }
        for(int i=1;i<=(2*n);i++)
        {
            if(a[i]%2==0)
                e.pb(i);
            else o.pb(i);
        }
        ll i=0,j=0,c=0;
        while(c<(n-1) && (i<o.size()-1))
        {
            if(i<(o.size()-1))
            {
                ll x=o[i];
                ll y=o[i+1];
            cout<<x<<" "<<y<<endl;
            i+=2;
            c++;
        }
        }
         while(c<(n-1) && (j<e.size()-1))
        {
            if(j<(e.size()-1))
            {
                ll x=e[j];
                ll y=e[j+1];
            cout<<x<<" "<<y<<endl;
            j+=2;
            c++;
            }
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i ,a, n) for (long long int i=a;i<=n;i++)
#define pb  push_back
#define mp make_pair
#define fp first
#define sp second
#define be(v) v.begin(),v.end()
typedef long long ll;
typedef vector<ll> vi ;
typedef vector<pair<ll , ll > >  vpi ;
const int ma1=3e5+5;
string no="NO",yes="YES";
const unsigned int MOD = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[2*n];
        vi o;
        vi e;
        for(int i=0;i<2*n;i++)
        {
            cin>>a[i];
            if(a[i]%2)
                o.pb(i);
            else e.push_back(i);
        }
        ll i=0,j=0,c=0;
        while(c<n-1 && i<o.size()-1)
        {
            cout<<o[i]+1<<" "<<o[i+1]+1<<endl;
            i+=2;
            c++;
        }
         while(c<n-1 && j<e.size()-1)

        {
            cout<<e[j]+1<<" "<<e[j+1]+1<<endl;
            j+=2;
            c++;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100001
int main()
{
	int t;
	cin>>t;
	int i,j;
	while(t--)
	{
		int n;
		cin>>n;
		int arr[2*n+1];
		for(i=0;i<2*n;i++)
		{
			cin>>arr[i];
		}
		vector<int> a;
		vector<int> b;
		for(i=0;i<2*n;i++)
		{
			if(arr[i]%2==0)
				a.push_back(i+1);
			else
				b.push_back(i+1);
		}
		int k=0;
		for(i=0;i<a.size()-1;i++)
		{
			if(k<n)
			{
				cout<<a[i]<<" "<<a[i+1]<<endl;
				k++;
				i++;
			}
		}
		if(k<n)
		{
			for(i=1;i<b.size()-1;i++)
			{
				if(k<n)
				{
					cout<<b[i]<<" "<<b[i+1]<<endl;
					i++;
					k++;
				}
				else
					break;
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100001
int main()
{
	int t;
	cin>>t;
	int i,j;
	while(t--)
	{
		int n;
		cin>>n;
		int arr[2*n+1];
		for(i=0;i<2*n;i++)
		{
			cin>>arr[i];
		}
		vector<int> a;
		vector<int> b;
		for(i=0;i<2*n;i++)
		{
			if(arr[i]%2==0)
				a.push_back(i+1);
			else
				b.push_back(i+1);
		}
		int k=0;
		for(i=0;i<a.size()-1;i++)
		{
			if(k<n)
			{
				cout<<a[i]<<" "<<a[i+1]<<endl;
				k++;
				i++;
			}
		}
		if(k<n)
		{
			for(i=0;i<b.size()-1;i++)
			{
				if(k<n-1)
				{
					cout<<b[i]<<" "<<b[i+1]<<endl;
					i++;
					k++;
				}
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100001
int main()
{
	int t;
	cin>>t;
	int i,j;
	while(t--)
	{
		int n;
		cin>>n;
		int arr[2*n+1];
		for(i=0;i<2*n;i++)
		{
			cin>>arr[i];
		}
		vector<int> a;
		vector<int> b;
		for(i=0;i<2*n;i++)
		{
			if(arr[i]%2==0)
				a.push_back(i+1);
			else
				b.push_back(i+1);
		}
		int k=0;

		for(i=0;i<a.size()-1;i++)
		{
			if(k<n-1)
			{
				cout<<a[i]<<" "<<a[i+1]<<endl;
				k++;
				i++;
			}
		}
		if(k<n-1)
		{
			for(i=0;i<b.size()-1;i++)
			{
				if(k<n-1)
				{
					cout<<b[i]<<" "<<b[i+1]<<endl;
					i++;
					k++;
				}
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100001
int main()
{
	int t;
	cin>>t;
	int i,j;
	while(t--)
	{
		int n;
		cin>>n;
		int arr[2*n+1];
		for(i=0;i<2*n;i++)
		{
			cin>>arr[i];
		}
		vector<int> a;
		vector<int> b;
		for(i=0;i<2*n;i++)
		{
			if(arr[i]%2==0)
				a.push_back(i+1);
			else
				b.push_back(i+1);
		}
		int k=0;
		if(a.size()!=0)
		{
			for(i=0;i<a.size()-1;i++)
			{
				if(k<n-1)
				{
					cout<<a[i]<<" "<<a[i+1]<<endl;
					k++;
					i++;
				}
			}
		}
		if(k<n-1 && b.size()!=0)
		{
			for(i=0;i<b.size()-1;i++)
			{
				if(k<n-1)
				{
					cout<<b[i]<<" "<<b[i+1]<<endl;
					i++;
					k++;
				}
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100001
int main()
{
	int t;
	cin>>t;
	int i,j;
	while(t--)
	{
		int n;
		cin>>n;
		int arr[2*n+1];
		for(i=0;i<2*n;i++)
		{
			cin>>arr[i];
		}
		vector<int> a;
		vector<int> b;
		for(i=0;i<2*n;i++)
		{
			if(arr[i]%2==0)
				a.push_back(i+1);
			else
				b.push_back(i+1);
		}
		int k=0;
		for(i=0;i<a.size()-1;i++)
		{
			if(k<n-1)
			{
				cout<<a[i]<<" "<<a[i+1]<<endl;
				k++;
				i++;
			}
		}
		if(k<n-1)
		{
			for(i=0;i<b.size()-1;i++)
			{
				if(k<n-1)
				{
					cout<<b[i]<<" "<<b[i+1]<<endl;
					i++;
					k++;
				}
				else
					break;
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100001
int main()
{
	int t;
	cin>>t;
	int i,j;
	while(t--)
	{
		int n;
		cin>>n;
		int arr[2*n+1];
		for(i=0;i<2*n;i++)
		{
			cin>>arr[i];
		}
		vector<int> a;
		vector<int> b;
		for(i=0;i<2*n;i++)
		{
			if(arr[i]%2==0)
				a.push_back(i+1);
			else
				b.push_back(i+1);
		}
		int k=0;
		for(i=1;i<a.size()-1;i++)
		{
			if(k<n)
				cout<<a[i]<<" "<<a[i+1]<<endl;
			k++;
		}
		if(k<(n-1))
		{
			for(i=1;i<b.size()-1;i++)
			{
				if(k<n-1)
					cout<<b[i]<<" "<<b[i+1]<<endl;
					else
					break;
				k++;
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100001
int main()
{
	int t;
	cin>>t;
	int i,j;
	while(t--)
	{
		int n;
		cin>>n;
		int arr[2*n+1];
		for(i=0;i<2*n;i++)
		{
			cin>>arr[i];
		}
		vector<int> a;
		vector<int> b;
		for(i=0;i<2*n;i++)
		{
			if(arr[i]%2==0)
				a.push_back(i+1);
			else
				b.push_back(i+1);
		}
		int k=0;
		for(i=0;i<a.size()-1;i++)
		{
			if(k<n-1)
			{
				cout<<a[i]<<" "<<a[i+1]<<endl;
				k++;
				i++;
			}
		}
		if(k<n-1)
		{
			for(i=0;i<b.size()-1;i++)
			{
				if(k<n-1)
				{
					cout<<b[i]<<" "<<b[i+1]<<endl;
					i++;
					k++;
				}
			}
		}
	}
	return 0;
}


/**
 *              "Bismillahir Rahmanir Rahim"
 *                 _                       _            __
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __      / /
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \    / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | |  / /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_| /_/
 *                   |___/
 *                 _                       _        ___   ___ _____
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __  / _ \ / _ \___  |
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \| | | | | | | / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | | |_| | |_| |/ /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_|\___/ \___//_/
 *                   |___/
 *
 *   email:      mdyamin007@yahoo.com
 *   website:    mdyamin007.github.io
 *   facebook:   fb.com/mdyamin007
 *   linkedIn:   linkedin.com/in/mdyamin
 *   created:    06.06.2020
 *
**/

#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back
#define mp make_pair
#define PI acos(-1)
#define ff first
#define ss second
#define sf scanf
#define pf printf
#define sf1(a) sf("%lld", &a)
#define sf2(a,b) sf("%lld %lld", &a, &b)
#define sf3(a,b,c) sf("%lld %lld %lld", &a, &b, &c)
#define sf4(a,b,c,d) sf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define sf5(a,b,c,d,e) sf("%lld %lld %lld %lld %lld", &a, &b, &c, &d, &e)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define INF (1e9)+7
#define RESET(a, b) memset(a, (b), sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define newline pf("\n")
#define newlinepp cout << '\n'
#define sfd(n) sf("%lf", &n)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define SIZE(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define on(n,i) n|=(1<<i)
#define isOn(n,i) n&(1<<i)
#define off(n,i) n = isOn(n,i) ? n ^ (1<<i) : n
#define GCD(a,b) __gcd(a,b)
#define lcm(a,b) ((a*b)/gcd(a,b))
#define watch(a) cout << (#a) << " is " << (a) << '\n'
#define watch2(a,b) cout << (#a) << " is " << (a) << " and " << (#b) << " is " << (b) << '\n'
#define MIN3(a,b,c) MIN(a, MIN(b,c))
#define MAX3(a,b,c) MAX(a, MAX(b,c))

using namespace std;

typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;

int fx[] = {-1, 1, 0, 0};
int fy[] = {0, 0, -1, 1};

/************************************/

void Solution() {
    int n;
    sf1(n);
    int arr[2*n+1];
    vi odds, evens;
    REP(i,n*2) {
        sf1(arr[i]);
    }
//    REP(i,SIZE(evens)) cout << evens[i] << ' ';
//    newline;
//    REP(i,SIZE(odds)) cout << odds[i] << ' ';
//    cout << '\n';
    bool marked[2*n];
    RESET(marked,0);
    int cnt = 0;
    vii vec;
    int g = 1000;
    REP(i,2*n) {
        if(marked[i]) continue;
        REP(j,2*n) {
            if(marked[j]) continue;
            if(i == j) continue;
            if(arr[i]+arr[j] % 2 == 0 or GCD(g,arr[i] + arr[j]) != 1) {
               // watch2(arr[i],arr[j]);
                vec.pb(mp(i+1,j+1));
                marked[j] = marked[i] = true;
                cnt++;
                if(cnt == n-1) j = i = 2 * n;
                break;
            }
        }
    }
    REP(i,SIZE(vec)) pf("%lld %lld\n", vec[i].first, vec[i].second);
}

int32_t main() {
    //FAST_IO
    #ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif

    int tc = 1;
	sf1(tc);
    //cin >> tc;

    FOR(tn,1,tc+1,1) {
        //pf("Case %lld:", tn);
        Solution();
	}

    return 0;
}


/**
 *              "Bismillahir Rahmanir Rahim"
 *                 _                       _            __
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __      / /
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \    / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | |  / /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_| /_/
 *                   |___/
 *                 _                       _        ___   ___ _____
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __  / _ \ / _ \___  |
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \| | | | | | | / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | | |_| | |_| |/ /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_|\___/ \___//_/
 *                   |___/
 *
 *   email:      mdyamin007@yahoo.com
 *   website:    mdyamin007.github.io
 *   facebook:   fb.com/mdyamin007
 *   linkedIn:   linkedin.com/in/mdyamin
 *   created:    06.06.2020
 *
**/

#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back
#define mp make_pair
#define PI acos(-1)
#define ff first
#define ss second
#define sf scanf
#define pf printf
#define sf1(a) sf("%lld", &a)
#define sf2(a,b) sf("%lld %lld", &a, &b)
#define sf3(a,b,c) sf("%lld %lld %lld", &a, &b, &c)
#define sf4(a,b,c,d) sf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define sf5(a,b,c,d,e) sf("%lld %lld %lld %lld %lld", &a, &b, &c, &d, &e)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define INF (1e9)+7
#define RESET(a, b) memset(a, (b), sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define newline pf("\n")
#define newlinepp cout << '\n'
#define sfd(n) sf("%lf", &n)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define SIZE(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define on(n,i) n|=(1<<i)
#define isOn(n,i) n&(1<<i)
#define off(n,i) n = isOn(n,i) ? n ^ (1<<i) : n
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a*b)/gcd(a,b))
#define watch(a) cout << (#a) << " is " << (a) << '\n'
#define watch2(a,b) cout << (#a) << " is " << (a) << " and " << (#b) << " is " << (b) << '\n'
#define MIN3(a,b,c) MIN(a, MIN(b,c))
#define MAX3(a,b,c) MAX(a, MAX(b,c))

using namespace std;

typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;

int fx[] = {-1, 1, 0, 0};
int fy[] = {0, 0, -1, 1};

/************************************/

void Solution() {
    int n;
    sf1(n);
    int arr[2*n+1];
    vi odds, evens;
    REP(i,n*2) {
        sf1(arr[i]);
        if(arr[i] & 1) odds.pb(i+1);
        else evens.pb(i+1);
    }
//    REP(i,SIZE(evens)) cout << evens[i] << ' ';
//    newline;
//    REP(i,SIZE(odds)) cout << odds[i] << ' ';
//    cout << '\n';
    if(SIZE(odds) >= 2) FOR(i,0,SIZE(odds)-1,2) {
        if(SIZE(odds)-i <= 2) continue;
        pf("%lld %lld\n", odds[i], odds[i+1]);
    }
    if(SIZE(evens) >= 2) FOR(i,0,SIZE(evens)-1,2) {
        if(SIZE(evens) <= 2) continue;
        pf("%lld %lld\n", evens[i], evens[i+1]);
    }
}

int32_t main() {
    //FAST_IO
    #ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif

    int tc = 1;
	sf1(tc);
    //cin >> tc;

    FOR(tn,1,tc+1,1) {
        //pf("Case %lld:", tn);
        Solution();
	}

    return 0;
}


/**
 *              "Bismillahir Rahmanir Rahim"
 *                 _                       _            __
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __      / /
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \    / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | |  / /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_| /_/
 *                   |___/
 *                 _                       _        ___   ___ _____
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __  / _ \ / _ \___  |
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \| | | | | | | / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | | |_| | |_| |/ /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_|\___/ \___//_/
 *                   |___/
 *
 *   email:      mdyamin007@yahoo.com
 *   website:    mdyamin007.github.io
 *   facebook:   fb.com/mdyamin007
 *   linkedIn:   linkedin.com/in/mdyamin
 *   created:    06.06.2020
 *
**/

#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back
#define mp make_pair
#define PI acos(-1)
#define ff first
#define ss second
#define sf scanf
#define pf printf
#define sf1(a) sf("%lld", &a)
#define sf2(a,b) sf("%lld %lld", &a, &b)
#define sf3(a,b,c) sf("%lld %lld %lld", &a, &b, &c)
#define sf4(a,b,c,d) sf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define sf5(a,b,c,d,e) sf("%lld %lld %lld %lld %lld", &a, &b, &c, &d, &e)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define INF (1e9)+7
#define RESET(a, b) memset(a, (b), sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define newline pf("\n")
#define newlinepp cout << '\n'
#define sfd(n) sf("%lf", &n)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define SIZE(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define on(n,i) n|=(1<<i)
#define isOn(n,i) n&(1<<i)
#define off(n,i) n = isOn(n,i) ? n ^ (1<<i) : n
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a*b)/gcd(a,b))
#define watch(a) cout << (#a) << " is " << (a) << '\n'
#define watch2(a,b) cout << (#a) << " is " << (a) << " and " << (#b) << " is " << (b) << '\n'
#define MIN3(a,b,c) MIN(a, MIN(b,c))
#define MAX3(a,b,c) MAX(a, MAX(b,c))

using namespace std;

typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;

int fx[] = {-1, 1, 0, 0};
int fy[] = {0, 0, -1, 1};

/************************************/

void Solution() {
    int n;
    sf1(n);
    int arr[2*n+1];
    vi odds, evens;
    REP(i,n*2) {
        sf1(arr[i]);
        if(arr[i] & 1) odds.pb(i+1);
        else evens.pb(i+1);
    }
//    REP(i,SIZE(evens)) cout << evens[i] << ' ';
//    newline;
//    REP(i,SIZE(odds)) cout << odds[i] << ' ';
//    cout << '\n';
    vii vec;
    for(int i = 0;i + 1 < SIZE(evens); i++) {
      vec.pb(mp(evens[i],evens[i+1]));
    }
    for(int i = 0;i + 1 < SIZE(odds); i++) {
      vec.pb(mp(odds[i],odds[i+1]));
    }
    REP(i,n-1) {
      pf("%lld %lld\n", vec[i].ff, vec[i].ss);
    }

}

int32_t main() {
    //FAST_IO
    /*#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif*/

    int tc = 1;
	sf1(tc);
    //cin >> tc;

    FOR(tn,1,tc+1,1) {
        //pf("Case %lld:", tn);
        Solution();
	}

    return 0;
}


/**
 *              "Bismillahir Rahmanir Rahim"
 *                 _                       _            __
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __      / /
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \    / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | |  / /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_| /_/
 *                   |___/
 *                 _                       _        ___   ___ _____
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __  / _ \ / _ \___  |
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \| | | | | | | / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | | |_| | |_| |/ /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_|\___/ \___//_/
 *                   |___/
 *
 *   email:      mdyamin007@yahoo.com
 *   website:    mdyamin007.github.io
 *   facebook:   fb.com/mdyamin007
 *   linkedIn:   linkedin.com/in/mdyamin
 *   created:    06.06.2020
 *
**/

#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back
#define mp make_pair
#define PI acos(-1)
#define ff first
#define ss second
#define sf scanf
#define pf printf
#define sf1(a) sf("%lld", &a)
#define sf2(a,b) sf("%lld %lld", &a, &b)
#define sf3(a,b,c) sf("%lld %lld %lld", &a, &b, &c)
#define sf4(a,b,c,d) sf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define sf5(a,b,c,d,e) sf("%lld %lld %lld %lld %lld", &a, &b, &c, &d, &e)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define INF (1e9)+7
#define RESET(a, b) memset(a, (b), sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define newline pf("\n")
#define newlinepp cout << '\n'
#define sfd(n) sf("%lf", &n)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define SIZE(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define on(n,i) n|=(1<<i)
#define isOn(n,i) n&(1<<i)
#define off(n,i) n = isOn(n,i) ? n ^ (1<<i) : n
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a*b)/gcd(a,b))
#define watch(a) cout << (#a) << " is " << (a) << '\n'
#define watch2(a,b) cout << (#a) << " is " << (a) << " and " << (#b) << " is " << (b) << '\n'
#define MIN3(a,b,c) MIN(a, MIN(b,c))
#define MAX3(a,b,c) MAX(a, MAX(b,c))

using namespace std;

typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;

int fx[] = {-1, 1, 0, 0};
int fy[] = {0, 0, -1, 1};

/************************************/

void Solution() {
    int n;
    sf1(n);
    int arr[2*n+1];
    vi odds, evens;
    REP(i,n*2) {
        sf1(arr[i]);
        if(arr[i] & 1) odds.pb(i+1);
        else evens.pb(i+1);
    }
//    REP(i,SIZE(evens)) cout << evens[i] << ' ';
//    newline;
//    REP(i,SIZE(odds)) cout << odds[i] << ' ';
//    cout << '\n';
    vii vec;
    for(int i = 0;i + 1 < SIZE(evens); i += 2) {
      vec.pb(mp(evens[i],evens[i+1]));
    }
    for(int i = 0;i + 1 < SIZE(odds); i += 2) {
      vec.pb(mp(odds[i],odds[i+1]));
    }
    REP(i,n-1) {
      pf("%lld %lld\n", vec[i].ff, vec[i].ss);
    }

}

int32_t main() {
    //FAST_IO
    /*#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif*/

    int tc = 1;
	sf1(tc);
    //cin >> tc;

    FOR(tn,1,tc+1,1) {
        //pf("Case %lld:", tn);
        Solution();
	}

    return 0;
}


/**
 *              "Bismillahir Rahmanir Rahim"
 *                 _                       _            __
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __      / /
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \    / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | |  / /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_| /_/
 *                   |___/
 *                 _                       _        ___   ___ _____
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __  / _ \ / _ \___  |
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \| | | | | | | / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | | |_| | |_| |/ /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_|\___/ \___//_/
 *                   |___/
 *
 *   email:      mdyamin007@yahoo.com
 *   website:    mdyamin007.github.io
 *   facebook:   fb.com/mdyamin007
 *   linkedIn:   linkedin.com/in/mdyamin
 *   created:    06.06.2020
 *
**/

#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back
#define mp make_pair
#define PI acos(-1)
#define ff first
#define ss second
#define sf scanf
#define pf printf
#define sf1(a) sf("%lld", &a)
#define sf2(a,b) sf("%lld %lld", &a, &b)
#define sf3(a,b,c) sf("%lld %lld %lld", &a, &b, &c)
#define sf4(a,b,c,d) sf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define sf5(a,b,c,d,e) sf("%lld %lld %lld %lld %lld", &a, &b, &c, &d, &e)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define INF (1e9)+7
#define RESET(a, b) memset(a, (b), sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define newline pf("\n")
#define newlinepp cout << '\n'
#define sfd(n) sf("%lf", &n)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define SIZE(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define on(n,i) n|=(1<<i)
#define isOn(n,i) n&(1<<i)
#define off(n,i) n = isOn(n,i) ? n ^ (1<<i) : n
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a*b)/gcd(a,b))
#define watch(a) cout << (#a) << " is " << (a) << '\n'
#define watch2(a,b) cout << (#a) << " is " << (a) << " and " << (#b) << " is " << (b) << '\n'
#define MIN3(a,b,c) MIN(a, MIN(b,c))
#define MAX3(a,b,c) MAX(a, MAX(b,c))

using namespace std;

typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;

int fx[] = {-1, 1, 0, 0};
int fy[] = {0, 0, -1, 1};

/************************************/

void Solution() {
    int n;
    sf1(n);
    int arr[2*n+1];
    vi odds, evens;
    REP(i,n*2) {
        sf1(arr[i]);
        if(arr[i] & 1) odds.pb(i+1);
        else evens.pb(i+1);
    }
//    REP(i,SIZE(evens)) cout << evens[i] << ' ';
//    newline;
//    REP(i,SIZE(odds)) cout << odds[i] << ' ';
//    cout << '\n';
    if(SIZE(evens) & 1 and SIZE(evens) != 0) evens.pop_back();
    int cnt = 0;
    FOR(i,0,SIZE(evens),2) {
        cnt++;
        pf("%lld %lld\n", evens[i], evens[i+1]);
    }
    FOR(i,0,SIZE(odds),2) {
      cnt++;
      pf("%lld %lld\n", odds[i], odds[i+1]);
      if(cnt == n-1) break;
    }
}

int32_t main() {
    //FAST_IO
    /*#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif*/

    int tc = 1;
	sf1(tc);
    //cin >> tc;

    FOR(tn,1,tc+1,1) {
        //pf("Case %lld:", tn);
        Solution();
	}

    return 0;
}


/**
 *              "Bismillahir Rahmanir Rahim"
 *                 _                       _            __
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __      / /
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \    / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | |  / /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_| /_/
 *                   |___/
 *                 _                       _        ___   ___ _____
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __  / _ \ / _ \___  |
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \| | | | | | | / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | | |_| | |_| |/ /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_|\___/ \___//_/
 *                   |___/
 *
 *   email:      mdyamin007@yahoo.com
 *   website:    mdyamin007.github.io
 *   facebook:   fb.com/mdyamin007
 *   linkedIn:   linkedin.com/in/mdyamin
 *   created:    06.06.2020
 *
**/

#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back
#define mp make_pair
#define PI acos(-1)
#define ff first
#define ss second
#define sf scanf
#define pf printf
#define sf1(a) sf("%lld", &a)
#define sf2(a,b) sf("%lld %lld", &a, &b)
#define sf3(a,b,c) sf("%lld %lld %lld", &a, &b, &c)
#define sf4(a,b,c,d) sf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define sf5(a,b,c,d,e) sf("%lld %lld %lld %lld %lld", &a, &b, &c, &d, &e)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define INF (1e9)+7
#define RESET(a, b) memset(a, (b), sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define newline pf("\n")
#define newlinepp cout << '\n'
#define sfd(n) sf("%lf", &n)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define SIZE(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define on(n,i) n|=(1<<i)
#define isOn(n,i) n&(1<<i)
#define off(n,i) n = isOn(n,i) ? n ^ (1<<i) : n
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a*b)/gcd(a,b))
#define watch(a) cout << (#a) << " is " << (a) << '\n'
#define watch2(a,b) cout << (#a) << " is " << (a) << " and " << (#b) << " is " << (b) << '\n'
#define MIN3(a,b,c) MIN(a, MIN(b,c))
#define MAX3(a,b,c) MAX(a, MAX(b,c))

using namespace std;

typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;

int fx[] = {-1, 1, 0, 0};
int fy[] = {0, 0, -1, 1};

/************************************/

void Solution() {
    int n;
    sf1(n);
    int arr[2*n+1];
    vi odds, evens;
    REP(i,n*2) {
        sf1(arr[i]);
        if(arr[i] & 1) odds.pb(i+1);
        else evens.pb(i+1);
    }
//    REP(i,SIZE(evens)) cout << evens[i] << ' ';
//    newline;
//    REP(i,SIZE(odds)) cout << odds[i] << ' ';
//    cout << '\n';
    evens.pop_back();
    odds.pop_back();
    FOR(i,0,SIZE(odds),2) {
        pf("%lld %lld\n", odds[i], odds[i+1]);
    }
    FOR(i,0,SIZE(evens),2) {
        pf("%lld %lld\n", evens[i], evens[i+1]);
    }
}

int32_t main() {
    //FAST_IO
    #ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif

    int tc = 1;
	sf1(tc);
    //cin >> tc;

    FOR(tn,1,tc+1,1) {
        //pf("Case %lld:", tn);
        Solution();
	}

    return 0;
}


/**
 *              "Bismillahir Rahmanir Rahim"
 *                 _                       _            __
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __      / /
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \    / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | |  / /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_| /_/
 *                   |___/
 *                 _                       _        ___   ___ _____
 *   _ __ ___   __| |_   _  __ _ _ __ ___ (_)_ __  / _ \ / _ \___  |
 *  | '_ ` _ \ / _` | | | |/ _` | '_ ` _ \| | '_ \| | | | | | | / /
 *  | | | | | | (_| | |_| | (_| | | | | | | | | | | |_| | |_| |/ /
 *  |_| |_| |_|\__,_|\__, |\__,_|_| |_| |_|_|_| |_|\___/ \___//_/
 *                   |___/
 *
 *   email:      mdyamin007@yahoo.com
 *   website:    mdyamin007.github.io
 *   facebook:   fb.com/mdyamin007
 *   linkedIn:   linkedin.com/in/mdyamin
 *   created:    06.06.2020
 *
**/

#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back
#define mp make_pair
#define PI acos(-1)
#define ff first
#define ss second
#define sf scanf
#define pf printf
#define sf1(a) sf("%lld", &a)
#define sf2(a,b) sf("%lld %lld", &a, &b)
#define sf3(a,b,c) sf("%lld %lld %lld", &a, &b, &c)
#define sf4(a,b,c,d) sf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define sf5(a,b,c,d,e) sf("%lld %lld %lld %lld %lld", &a, &b, &c, &d, &e)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define INF (1e9)+7
#define RESET(a, b) memset(a, (b), sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define newline pf("\n")
#define newlinepp cout << '\n'
#define sfd(n) sf("%lf", &n)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define SIZE(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define on(n,i) n|=(1<<i)
#define isOn(n,i) n&(1<<i)
#define off(n,i) n = isOn(n,i) ? n ^ (1<<i) : n
#define GCD(a,b) __gcd(a,b)
#define lcm(a,b) ((a*b)/gcd(a,b))
#define watch(a) cout << (#a) << " is " << (a) << '\n'
#define watch2(a,b) cout << (#a) << " is " << (a) << " and " << (#b) << " is " << (b) << '\n'
#define MIN3(a,b,c) MIN(a, MIN(b,c))
#define MAX3(a,b,c) MAX(a, MAX(b,c))

using namespace std;

typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;

int fx[] = {-1, 1, 0, 0};
int fy[] = {0, 0, -1, 1};

/************************************/

int num;

void sieve(int n) {
    num = 1;
    bool isPrime[n+1];
    RESET(isPrime,0);
    vi primes;
    for(int i = 3;i * i <= n; i += 2) {
        if(!isPrime[i]) {
            for(int j = i * i;j <= n;j += (i << 1)) {
                isPrime[j] = true;
            }
        }
    }
    primes.pb(2);
    FOR(i,3,n,2) {
        if(!isPrime[i]) primes.pb(i);
    }

    REP(i,SIZE(primes)) num *= primes[i];
}

void Solution() {
    int n;
    sf1(n);
    int arr[2*n+1];
    vi odds, evens;
    REP(i,n*2) {
        sf1(arr[i]);
    }
//    REP(i,SIZE(evens)) cout << evens[i] << ' ';
//    newline;
//    REP(i,SIZE(odds)) cout << odds[i] << ' ';
//    cout << '\n';
    bool marked[2*n];
    RESET(marked,0);
    int cnt = 0;
    vii vec;
    int g = num;
    REP(i,2*n) {
        if(marked[i]) continue;
        REP(j,2*n) {
            if(marked[j]) continue;
            if(i == j) continue;
            if(GCD(arr[i] + arr[j], g) != 1) {
               // watch2(arr[i],arr[j]);
                g = GCD(arr[i]+arr[j],g);
                vec.pb(mp(i+1,j+1));
                marked[j] = marked[i] = true;
                cnt++;
                if(cnt == n-1) j = i = 2 * n;
                break;
            }
        }
    }
    REP(i,SIZE(vec)) pf("%lld %lld\n", vec[i].first, vec[i].second);
}

int32_t main() {
    sieve(1000);
    //FAST_IO
    #ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif

    int tc = 1;
	sf1(tc);
    //cin >> tc;

    FOR(tn,1,tc+1,1) {
        //pf("Case %lld:", tn);
        Solution();
	}

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define mo unordered_map<ll,ll>
int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
    ll n;
    cin>>n;
    n = 2*n;
    ll arr[n+2];
    ll ars[n+2];
    fr(i,0,n){
    	cin>>arr[i];
    	ars[i] = arr[i];
    }
    vector<pair<ll,ll>> vc;

    sort(ars,ars+n);
    ll mini = ars[0];
    ll pu[n+2];
    ll ma = ars[n-1]+ars[n-1];
    ll ro ;
    for(ll i = max(ll(2),mini);i<=ma;i++){
    	ll flg = 0;
    	mo ms;
    for(ll j = 0;j<n;j++){
    	ll d = arr[j]%i;
    	ms[d]++;
    	pu[j] = d;

    }
    for(auto it = ms.begin();it != ms.end();it++){
    	if(it->first == 0){
    		if(it->second%2 == 0){
    			it->second = 0;
    		}
    		else{
    			it->second = 1;
    		}
    	}
    	else{
    		if(it->second>0){
    			ll cd = i-it->first;
    		if(cd>=0 && ms[cd]>0){
    			ll ae = min(ms[cd],it->second);
    		ms[cd] -= ae;
    		it->second -= ae;
    	}
    		}

    		}

    }
    ll af = 0;
    for(auto it = ms.begin();it != ms.end();it++){
    	if(it->second>0){
    		af++;
    	}
    }
    mo m;
    if(af == 0 || af == 2){
    	ro = i;
    	//cout<<ro<<"\n";
    	fr(bq,0,n){
    		fr(er,0,n){
    			if(bq != er && m[er] != 1 && m[bq] != 1 && (pu[bq]+pu[er])%i == 0){
    				vc.push_back(make_pair(bq+1,er+1));
    				m[bq] = 1;
    				m[er] = 1;
    			}
    		}
    	}
    	if(ll(vc.size())>=n/2-1){
    		flg = 1;

    	}
    	else{
    		vc.clear();
    	}

    }
    if(flg == 1){
    	break;
    }

    }
    fr(i,0,n/2 -1){
    	cout<<vc[i].first<<" "<<vc[i].second<<"\n";

    }

    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define unordered_map<ll,ll>
int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
    ll n;
    cin>>n;
    n = 2*n;
    ll arr[n+2];
    ll ars[n+2];
    fr(i,0,n){
    	cin>>arr[i];
    	ars[i] = arr[i];
    }
    vector<pair<ll,ll>> vc;

    sort(ars,ars+n);
    ll mini = ars[0];
    ll pu[n+2];
    ll ma = ars[n-2]+ars[n-1];
    ll ro ;
    for(ll i = max(ll(2),mini);i<=ma;i++){
    	ll flg = 0;
    	mo ms;
    for(ll j = 0;j<n;j++){
    	ll d = arr[j]%i;
    	ms[d]++;
    	pu[j] = d;

    }
    for(auto it = ms.begin();it != ms.end();it++){
    	if(it->first == 0){
    		if(it->second%2 == 0){
    			it->second = 0;
    		}
    		else{
    			it->second = 1;
    		}
    	}
    	else{
    		if(it->second>0){
    			ll cd = i-it->first;
    		if(cd>=0){
    			ll ae = min(ms[cd],it->second);
    		ms[cd] -= ae;
    		it->second -= ae;
    	}
    		}

    		}

    }
    ll af = 0;
    for(auto it = ms.begin();it != ms.end();it++){
    	if(it->second>0){
    		af++;
    	}
    }
    mo m;
    if(af == 0 || af == 2){
    	ro = i;
    	//cout<<ro<<"\n";
    	fr(bq,0,n){
    		fr(er,0,n){
    			if(bq != er && m[er] != 1 && m[bq] != 1 && (pu[bq]+pu[er])%i == 0){
    				vc.push_back(make_pair(bq+1,er+1));
    				m[bq] = 1;
    				m[er] = 1;
    			}
    		}
    	}
    	if(ll(vc.size())>=n/2-1){
    		flg = 1;

    	}
    	else{
    		vc.clear();
    	}

    }
    if(flg == 1){
    	break;
    }

    }
    fr(i,0,n/2 -1){
    	cout<<vc[i].first<<" "<<vc[i].second<<"\n";

    }

    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define mo map<ll,ll>
int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
    ll n;
    cin>>n;
    n = 2*n;
    ll arr[n+2];
    ll ars[n+2];
    fr(i,0,n){
    	cin>>arr[i];
    	ars[i] = arr[i];
    }
    vector<pair<ll,ll>> vc;

    sort(ars,ars+n);
    ll mini = ars[0];
    ll pu[n+2];
    ll ma = ars[n-1]+ars[n-1];
    ll ro ;
    for(ll i = max(ll(2),mini);i<=ma;i++){
    	ll flg = 0;
    	mo ms;
    for(ll j = 0;j<n;j++){
    	ll d = arr[j]%i;
    	ms[d]++;
    	pu[j] = d;

    }
    for(auto it = ms.begin();it != ms.end();it++){
    	if(it->first == 0){
    		if(it->second%2 == 0){
    			it->second = 0;
    		}
    		else{
    			it->second = 1;
    		}
    	}
    	else{
    		if(it->second>0){
    			ll cd = i-it->first;
    		if(cd>=0){
    			ll ae = min(ms[cd],it->second);
    		ms[cd] -= ae;
    		it->second -= ae;
    	}
    		}

    		}

    }
    ll af = 0;
    for(auto it = ms.begin();it != ms.end();it++){
    	if(it->second>0){
    		af++;
    	}
    }
    mo m;
    if(af == 0 || af == 2){
    	ro = i;
    	//cout<<ro<<"\n";
    	fr(bq,0,n){
    		fr(er,0,n){
    			if(bq != er && m[er] != 1 && m[bq] != 1 && (pu[bq]+pu[er])%i == 0){
    				vc.push_back(make_pair(bq+1,er+1));
    				m[bq] = 1;
    				m[er] = 1;
    			}
    		}
    	}
    	if(ll(vc.size())>=n/2-1){
    		flg = 1;

    	}
    	else{
    		vc.clear();
    	}

    }
    if(flg == 1){
    	break;
    }

    }
    fr(i,0,n/2 -1){
    	cout<<vc[i].first<<" "<<vc[i].second<<"\n";

    }

    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define mo map<ll,ll>
int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
    	ll n;
    	cin>>n;
    	n = 2*n;
    	ll arr[n+2];
    	fr(i,0,n){
    		cin>>arr[i];
    	}
    	mo ms;
    	vector<pair<ll,ll>> v;
    	ll flg = 0;
    	fr(i,0,n){
    		if(arr[i]%2 ==0){
    			flg = 0;
    		}
    		else{
    			flg = 1;
    		}
    		if(ms[i] != 1){
    			fr(j,0,n){
    		if(flg == 0 && arr[j]%2 == 0 && ms[j] != 1 && i != j){
    			ms[j] = 1;
    			ms[i] = 1;

    			v.push_back(make_pair(i+1,j+1));
    			break;

    		}
    		if(flg == 1 && arr[j]%2 == 1 && ms[j] != 1 && i != j){
    				ms[j] = 1;
    			ms[i] = 1;
    			v.push_back(make_pair(i+1,j+1));
    			break;

    		}

    		}

    		}

    	}

    	fr(i,0,n/2-1){
    		cout<<v[i].first<<" "<<v[i].second<<"\n";
    	}
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define mo map<ll,ll>
int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
    ll n;
    cin>>n;
    n = 2*n;
    ll arr[n+2];
    ll ars[n+2];
    fr(i,0,n){
    	cin>>arr[i];
    	ars[i] = arr[i];
    }
    vector<pair<ll,ll>> vc;

    sort(ars,ars+n);
    ll mini = ars[0];
    ll pu[n+2];
    ll ma = ars[n-2]+ars[n-1];
    ll ro ;
    for(ll i = max(ll(2),mini);i<=ma;i++){
    	ll flg = 0;
    	mo ms;
    for(ll j = 0;j<n;j++){
    	ll d = arr[j]%i;
    	ms[d]++;
    	pu[j] = d;

    }
    for(auto it = ms.begin();it != ms.end();it++){
    	if(it->first == 0 && it->second>=2){
    		if(it->second%2 == 0){
    			it->second = 0;
    		}
    		else{
    			it->second = 1;
    		}
    	}
    	else{
    		ll cd = i-it->first;
    		if(cd>=0){
    			ll ae = min(ms[cd],it->second);
    		ms[cd] -= ae;
    		it->second -= ae;
    	}
    		}

    }
    ll af = 0;
    for(auto it = ms.begin();it != ms.end();it++){
    	if(it->second>0){
    		af++;
    	}
    }
    mo m;
    if(af == 0 || af == 2){
    	ro = i;
    	//cout<<ro<<"\n";
    	fr(bq,0,n){
    		fr(er,0,n){
    			if(bq != er && m[er] != 1 && m[bq] != 1 && (pu[bq]+pu[er])%i == 0){
    				vc.push_back(make_pair(bq+1,er+1));
    				m[bq] = 1;
    				m[er] = 1;
    			}
    		}
    	}
    	flg = 1;
    }
    if(flg == 1){
    	break;
    }

    }
    fr(i,0,n/2 -1){
    	cout<<vc[i].first<<" "<<vc[i].second<<"\n";

    }

    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define mo unordered_map<ll,ll>
int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
    ll n;
    cin>>n;
    n = 2*n;
    ll arr[n+2];
    ll ars[n+2];
    fr(i,0,n){
    	cin>>arr[i];
    	ars[i] = arr[i];
    }
    vector<pair<ll,ll>> vc;

    sort(ars,ars+n);
    ll mini = ars[0];
    ll pu[n+2];
    ll ma = ars[n-2]+ars[n-1];
    ll ro ;
    for(ll i = max(ll(2),mini);i<=ma;i++){
    	ll flg = 0;
    	mo ms;
    for(ll j = 0;j<n;j++){
    	ll d = arr[j]%i;
    	ms[d]++;
    	pu[j] = d;

    }
    for(auto it = ms.begin();it != ms.end();it++){
    	if(it->first == 0){
    		if(it->second%2 == 0){
    			it->second = 0;
    		}
    		else{
    			it->second = 1;
    		}
    	}
    	else{
    		if(it->second>0){
    			ll cd = i-it->first;
    		if(cd>=0){
    			ll ae = min(ms[cd],it->second);
    		ms[cd] -= ae;
    		it->second -= ae;
    	}
    		}

    		}

    }
    ll af = 0;
    for(auto it = ms.begin();it != ms.end();it++){
    	if(it->second>0){
    		af++;
    	}
    }
    mo m;
    if(af == 0 || af == 2){
    	ro = i;
    	//cout<<ro<<"\n";
    	fr(bq,0,n){
    		fr(er,0,n){
    			if(bq != er && m[er] != 1 && m[bq] != 1 && (pu[bq]+pu[er])%i == 0){
    				vc.push_back(make_pair(bq+1,er+1));
    				m[bq] = 1;
    				m[er] = 1;
    			}
    		}
    	}
    	if(ll(vc.size())>=n/2-1){
    		flg = 1;

    	}
    	else{
    		vc.clear();
    	}

    }
    if(flg == 1){
    	break;
    }

    }
    fr(i,0,n/2 -1){
    	cout<<vc[i].first<<" "<<vc[i].second<<"\n";

    }

    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define mo unordered_map<ll,ll>
int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
    ll n;
    cin>>n;
    n = 2*n;
    ll arr[n+2];
    ll ars[n+2];
    fr(i,0,n){
    	cin>>arr[i];
    	ars[i] = arr[i];
    }
    vector<pair<ll,ll>> vc;

    sort(ars,ars+n);
    ll mini = ars[0];
    ll pu[n+2];
    ll ma = ars[n-2]+ars[n-1];
    ll ro ;
    set<ll> ph;
    for(ll i = max(ll(2),mini);i<=ma;i++){
    	ll flg = 0;
    	mo ms;
    for(ll j = 0;j<n;j++){
    	ll d = arr[j]%i;
    	ph.insert(d);
    	ms[d]++;
    	pu[j] = d;

    }
    for(auto gh = ph.begin();gh != ph.end();gh++){
    	if(*gh == 0){
    		if(ms[*gh]%2 == 0){
    			ms[*gh] = 0;
    		}
    		else{
    			ms[*gh] = 1;
    		}
    	}
    	else{
    		if(ms[*gh]>0){
    			ll cd = i-*gh;
    		if(cd>=0 && ms[cd]>0){
    			ll ae = min(ms[cd],ms[*gh]);
    		ms[cd] -= ae;
    		ms[*gh] -= ae;
    	}
    		}

    		}

    }
    ll af = 0;
    for(auto gh = ph.begin();gh != ph.end();gh++){
    	if(ms[*gh]>0){
    		af++;
    	}
    }
    mo m;
    if(af == 0 || af == 2){
    	ro = i;
    	//cout<<ro<<"\n";
    	fr(bq,0,n){
    		fr(er,0,n){
    			if(bq != er && m[er] != 1 && m[bq] != 1 && (pu[bq]+pu[er])%i == 0){
    				vc.push_back(make_pair(bq+1,er+1));
    				m[bq] = 1;
    				m[er] = 1;
    			}
    		}
    	}
    	if(ll(vc.size())>=n/2-1){
    		flg = 1;

    	}
    	else{
    		vc.clear();
    	}

    }
    if(flg == 1){
    	break;
    }

    }
    fr(i,0,n/2 -1){
    	cout<<vc[i].first<<" "<<vc[i].second<<"\n";

    }

    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define mo unordered_map<ll,ll>
int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
    ll n;
    cin>>n;
    n = 2*n;
    ll arr[n+2];
    ll ars[n+2];
    fr(i,0,n){
    	cin>>arr[i];
    	ars[i] = arr[i];
    }
    vector<pair<ll,ll>> vc;

    sort(ars,ars+n);
    ll mini = ars[0];
    ll pu[n+2];
    ll ma = ars[n-2]+ars[n-1];
    ll ro ;
    set<ll> ph;
    for(ll i = max(ll(2),mini);i<=ma;i++){
    	ll flg = 0;
    	mo ms;
    for(ll j = 0;j<n;j++){
    	ll d = arr[j]%i;
    	ph.insert(d);
    	ms[d]++;
    	pu[j] = d;

    }
    for(auto gh = ph.begin();gh != ph.end();gh++){
    	if(*gh == 0){
    		if(ms[*gh]%2 == 0){
    			ms[*gh] = 0;
    		}
    		else{
    			ms[*gh] = 1;
    		}
    	}
    	else{
    		if(ms[*gh]>0){
    			ll cd = i-*gh;
    		if(cd>=0 && ms[cd]>0){
    			ll ae = min(ms[cd],ms[*gh]);
    		ms[cd] -= ae;
    		ms[*gh] -= ae;
    	}
    		}

    		}

    }
    ll af = 0;
    for(auto gh = ph.begin();gh != ph.end();gh++){
    	if(ms[*gh]>0){
    		af++;
    	}
    }
    mo m;
    if(af == 0 || af == 2){
    	ro = i;
    	//cout<<ro<<"\n";
    	fr(bq,0,n){
    		fr(er,0,n){
    			if(bq != er && m[er] != 1 && m[bq] != 1 && (pu[bq]+pu[er])%i == 0){
    				vc.push_back(make_pair(bq+1,er+1));
    				m[bq] = 1;
    				m[er] = 1;
    			}
    		}
    	}
    	if(ll(vc.size())>=(n/2)-1){
    		flg = 1;

    	}
    	else{
    		vc.clear();
    	}

    }
    if(flg == 1){
    	break;
    }

    }
    ll mv = n/2;
    mv--;
    fr(i,0,min(ll(vc.size()),mv)){
    	cout<<vc[i].first<<" "<<vc[i].second<<"\n";

    }

    }
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

void solve()
{
	int n;
	cin>>n;

	// vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if(even.size()%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<even.size();i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=1;i<odd.size();i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
		return;
	}
	if(even.size()>odd.size())
	{
				for(int i=2;i<even.size();i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=0;i<odd.size();i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<even.size();i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=2;i<odd.size();i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}

// cout<<endl;
}

int main()
{
getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

void getio()
{
     fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
	int n;
	cin>>n;

	// vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if(even.size()%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=1;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
		return;
	}
	if(even.size()>odd.size())
	{
				for(int i=2;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=0;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=2;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
	}
}

int main()
{
getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

void getio()
{
     fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
	int n;
	cin>>n;

	vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		a[i].second=x;
		a[i].first=i;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if(even.size()%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=1;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
		return;
	}
	if(even.size()>odd.size())
	{
				for(int i=2;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=0;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=2;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
	}
}

int main()
{
getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

void getio()
{
     fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
	int n;
	cin>>n;

	vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		a[i].second=x;
		a[i].first=i;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if(even.size()%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=1;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
		return;
	}
	if(int(even.size())>int(odd.size()))
	{
				for(int i=2;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=0;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=2;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
	}
}

int main()
{
getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

void getio()
{
     fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
	int n;
	cin>>n;

	vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		a[i].second=x;
		a[i].first=i;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if(even.size()%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=1;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
		cout<<endl;
		return;
	}
	if(even.size()>odd.size())
	{
				for(int i=2;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=0;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=2;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}
	cout<<endl;

// cout<<endl;
}

int main()
{
getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

void solve()
{
	int n;
	cin>>n;

	// vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if(even.size()%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<even.size();i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=1;i<odd.size();i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
		return;
	}
	if(even.size()>odd.size())
	{
				for(int i=2;i<even.size();i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=0;i<odd.size();i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<even.size();i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=2;i<odd.size();i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}

// cout<<endl;
}

int main()
{
// getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

void getio()
{
     fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
	int n;
	cin>>n;

	vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		a[i].second=x;
		a[i].first=i;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if(int(even.size())%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=1;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
		cout<<endl;
		return;
	}
	if(int(even.size())>int(odd.size()))
	{
				for(int i=2;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=0;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=2;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}
	cout<<endl;

// cout<<endl;
}

int main()
{
getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

void getio()
{
     fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
	int n;
	cin>>n;

	// vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		// a[i].second=x;
		// a[i].first=i;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if(int(even.size())%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=1;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
		return;
	}
	if(int(even.size())>int(odd.size()))
	{
				for(int i=2;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=0;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=2;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
	}
}

int main()
{
getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

void getio()
{
     fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
	int n;
	cin>>n;
	vector<pair<int,int>> a(2*n);

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		a[i].second=x;
		a[i].first=i;
	}
	sort(all(a),sortbysec);
	for(int i=2;i<2*n-1;i+=2)
	{
		cout<<a[i].first<<" "<<a[i+1].first<<endl;
	}
// cout<<endl;
}

int main()
{
getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

void getio()
{
     fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
	int n;
	cin>>n;

	// vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if(int(even.size())%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=1;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
		return;
	}
	if(int(even.size())>int(odd.size()))
	{
				for(int i=2;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=0;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=2;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}

// cout<<endl;
}

int main()
{
getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

// bool sortbysec(const pair<int,int> &a,
//               const pair<int,int> &b)
// {
//     return (a.second < b.second);
// }

// void getio()
// {
//      fast
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
// }

void solve()
{
	int n;
	cin>>n;

	// vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		// a[i].second=x;
		// a[i].first=i;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if(even.size()%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=1;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
		return;
	}
	if(even.size()>odd.size())
	{
				for(int i=2;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=0;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<even.size()-1;i+=2)
		{
			cout<<even[i].first<<" ";if(i+1<even.size())cout<<even[i+1].first<<endl;
		}
			for(int i=2;i<odd.size()-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<odd.size())cout<<odd[i+1].first<<endl;
		}
	}
}

int main()
{
// getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

void getio()
{
     fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
	int n;
	cin>>n;

	// vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if((even.size())%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=1;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
		return;
	}
	if(int(even.size())>int(odd.size()))
	{
				for(int i=2;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=0;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" "<<even[i+1].first<<endl;
		}
			for(int i=2;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" "<<odd[i+1].first<<endl;
		}
	}

// cout<<endl;
}

int main()
{
getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace  std;

typedef  long  long int ll;
typedef  vector<int> vi;
#define  fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  all(x) x.begin(), x.end()
const ll mod = (ll)(1e9 + 7);
const double pi = 3.14159265358979323846;

// bool sortbysec(const pair<int,int> &a,
//               const pair<int,int> &b)
// {
//     return (a.second < b.second);
// }

// void getio()
// {
//      fast
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
// }

void solve()
{
	int n;
	cin>>n;

	// vector<pair<int,int>> a(2*n);
	vector<pair<int,int>> even;
	vector<pair<int,int>> odd;

	for(int i=0;i<2*n;i++)
	{
		int x;
		cin>>x;
		// a[i].second=x;
		// a[i].first=i;
		if(x%2)odd.pb({i+1,x});
		else even.pb({i+1,x});
	}
	if(int(even.size())%2)
	{
		// cout<<even[0].first<<" "<<odd[0].first<<endl;
		for(int i=1;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<int(even.size()))cout<<even[i+1].first<<endl;
		}
			for(int i=1;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<int(odd.size()))cout<<odd[i+1].first<<endl;
		}
		return;
	}
	if(int(even.size())>int(odd.size()))
	{
				for(int i=2;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" ";
			if(i+1<int(even.size()))cout<<even[i+1].first<<endl;
		}
			for(int i=0;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<int(odd.size()))cout<<odd[i+1].first<<endl;
		}
	}
	else
	{

				for(int i=0;i<int(even.size())-1;i+=2)
		{
			cout<<even[i].first<<" ";if(i+1<int(even.size()))cout<<even[i+1].first<<endl;
		}
			for(int i=2;i<int(odd.size())-1;i+=2)
		{
			cout<<odd[i].first<<" ";
			if(i+1<int(odd.size()))cout<<odd[i+1].first<<endl;
		}
	}
}

int main()
{
// getio();
int t; cin>>t; while(t--)
solve();
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e3 + 5;
int ar[N];

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int t; scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		for (int i = 0; i < 2 * n; i++) {
			scanf("%d", ar + i);
		}
		if (n == 2) {
			printf("%d %d\n", ar[2], ar[3]);
			continue;
		}
		sort(ar+2, ar + 2 * n, [](int& f, int& s) {
			if (f&1 && (s&1)^1)return true;
			if(f%2 == s%2)return f < s;
			});

		int i = 2;
		n--;
		while (n) {
			if (ar[i] % 2 == ar[i + 1] % 2)
				printf("%d %d\n", ar[i], ar[i + 1]), n--;
			++i;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	const int N = 1e3 + 5;
	pair<int, int> ar[N] = {  } ;
	int t; scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		for (int i = 0; i < 2 * n; i++) {
			int x; scanf("%d", &x);
			ar[i] = { x, i };
		}

		sort(ar, ar + 2 * n, [](pair<int, int>& f, pair<int, int>& s) {
			if (f.first &1 && (s.first &1)^1)return true;
			return false;
			});

		int i = 0;
		n--;
		while (n) {
			if (ar[i].first % 2 == ar[i + 1].first % 2)
				printf("%d %d\n", ar[i].second+1, ar[i + 1].second + 1), n--, ++i;
			++i;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e3 + 5;
int ar[N];

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int t; scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		for (int i = 0; i < 2 * n; i++) {
			scanf("%d", ar + i);
		}
		if (n == 2) {
			printf("%d %d\n", ar[2], ar[3]);
			continue;
		}
		sort(ar+2, ar + 2 * n, [](int f, int s) {
			if (f&1 && (s&1)^1)return true;
			if(f%2 == s%2)return f < s;
			});

		int i = 2;
		n--;
		while (n) {
			if (ar[i] % 2 == ar[i + 1] % 2)
				printf("%d %d\n", ar[i], ar[i + 1]), n--;
			++i;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	const int N = 1e3 + 5;
	pair<int, int> ar[N] = {  } ;
	int t; scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		for (int i = 0; i < 2 * n; i++) {
			int x; scanf("%d", &x);
			ar[i] = { x, i };
		}
		if (n == 2) {
			printf("1 2\n");
			continue;
		}
		sort(ar, ar + 2 * n, [](pair<int, int>& f, pair<int, int>& s) {
			if (f.first &1 && (s.first &1)^1)return true;
			return false;
			});

		int i = 0;
		n--;
		while (n) {
			if (ar[i].first % 2 == ar[i + 1].first % 2)
				printf("%d %d\n", ar[i].second+1, ar[i + 1].second + 1), n--, ++i;
			++i;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	const int N = 1e3 + 5;
	pair<int, int> ar[N] = {  } ;
	int t; scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		for (int i = 0; i < 2 * n; i++) {
			int x; scanf("%d", &x);
			ar[i] = { x, i };
		}
		if (n == 2) {
			printf("3 4\n");
			continue;
		}
		sort(ar, ar + 2 * n, [](pair<int, int>& f, pair<int, int>& s) {
			if (f.first &1 && (s.first &1)^1)return true;
			return false;
			});

		int i = 0;
		n--;
		while (n) {
			if (ar[i].first % 2 == ar[i + 1].first % 2)
				printf("%d %d\n", ar[i].second+1, ar[i + 1].second + 1), n--, ++i;
			++i;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e3 + 5;
pair<int, int> ar[N];

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int t; scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		for (int i = 0; i < 2 * n; i++) {
			int x; scanf("%d", &x);
			ar[i] = { x, i };
		}
		if (n == 2) {
			printf("3 4\n");
			continue;
		}
		sort(ar+2, ar + 2 * n, [](pair<int, int>& f, pair<int, int>& s) {
			if (f.first &1 && (s.first &1)^1)return true;
			return false;
			});

		int i = 2;
		n--;
		while (n) {
			if (ar[i].first % 2 == ar[i + 1].first % 2)
				printf("%d %d\n", ar[i].second+1, ar[i + 1].second + 1), n--;
			++i;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int t; scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		vector<int> odd, even;
		for (int i = 1; i <= 2 * n; i++) {
			int x; scanf("%d", &x);
			if (x & 1) odd.push_back(i);
			else even.push_back(i);
		}
		--n;
		for (int i = 1; i < odd.size() && n--; i += 2) {
			printf("%d %d\n", odd[i - 1], odd[i]);
		}
		for (int i = 1; i < even.size() && n--; i += 2) {
			printf("%d %d\n", even[i - 1], even[i]);
		}

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e3 + 5;
int ar[N];

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int t; scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		for (int i = 0; i < 2 * n; i++) {
			scanf("%d", ar + i);
		}
		if (n == 2) {
			printf("%d %d\n", ar[2], ar[3]);
			continue;
		}
		sort(ar+2, ar + 2 * n, [](int& f, int& s) {
			if (f&1 && (s&1)^1)return true;
			return false;
			});

		int i = 2;
		n--;
		while (n) {
			if (ar[i] % 2 == ar[i + 1] % 2)
				printf("%d %d\n", ar[i], ar[i + 1]), n--;
			++i;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e3 + 5;
pair<int, int> ar[N];

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int t; scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		for (int i = 0; i < 2 * n; i++) {
			int x; scanf("%d", &x);
			ar[i] = { x, i };
		}
		if (n == 2) {
			printf("3 4\n");
			continue;
		}
		sort(ar+2, ar + 2 * n, [](pair<int, int>& f, pair<int, int>& s) {
			if (f.first &1 && (s.first &1)^1)return true;
			return false;
			});

		int i = 2;
		n--;
		while (n) {
			if (ar[i].first % 2 == ar[i + 1].first % 2)
				printf("%d %d\n", ar[i].second+1, ar[i + 1].second + 1), n--, ++i;
			++i;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e3 + 5;
int ar[N];

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int t; scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		for (int i = 0; i < 2 * n; i++) {
			scanf("%d", ar + i);
		}
		//puts("her");
		sort(ar, ar + n, [](int f, int s) {
			if (f & 1 && s&1^1)return 1;
			return 0;
			});

		int i = 0;
		n--;
		while (n) {
			if (ar[i] % 2 == ar[i + 1] % 2)
				printf("%d %d\n", ar[i], ar[i + 1]), n--;
			++i;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e3 + 5;
int ar[N];

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int t; scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		for (int i = 0; i < 2 * n; i++) {
			scanf("%d", ar + i);
		}
		if (n == 2) {
			printf("%d %d\n", ar[2], ar[3]);
			continue;
		}
		sort(ar+2, ar + 2 * n, [](int f, int s) {
			if (f&1 && s&1^1)return true;
			if(f%2 == s%2)return f < s;
			});

		int i = 2;
		n--;
		while (n) {
			if (ar[i] % 2 == ar[i + 1] % 2)
				printf("%d %d\n", ar[i], ar[i + 1]), n--;
			++i;
		}
	}
	return 0;
}