#define LOCAL
#include<bits/stdc++.h>
#include<unistd.h>
#include<bits/extc++.h>
//#define getchar my_gechar
#define ll long long
#define lll __int128
#define db double
#define ldb long double
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define vec Point
#define fill0(a) memset(a,0,sizeof(a))
#define fill1(a) memset(a,-1,sizeof(a))
#define fillbig(a) memset(a,63,sizeof(a))
// #define max(a,b) ((a)<(b)?(b):(a))
// #define min(a,b) ((a)<(b)?(a):(b))
#define vi vector<int>
#define vl vector<ll>
#define lowbit(x) (x)&(-x)
//#define sort stable_sort
using namespace std;
using namespace __gnu_pbds;
char buffer[32769];
unsigned li = 0;
inline char my_gechar(){
if(buffer[li] == '\0') buffer[read(0, buffer, 32768)] = '\0',li = 0;
return buffer[li++];
}
namespace ly
{
namespace IO
{
#ifndef LOCAL
constexpr auto maxn=1<<20;
char in[maxn],out[maxn],*p1=in,*p2=in,*p3=out;
#define flush() (fwrite(out,1,p3-out,stdout))
#define putchar(x) (p3==out+maxn&&(flush(),p3=out),*p3++=(x))
class Flush{public:~Flush(){flush();}}_;
#endif
namespace usr
{
template<typename type>
inline type read(type &x)
{
x=0;bool flag(0);char ch=getchar();
while(!isdigit(ch)) flag^=ch=='-',ch=getchar();
while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return flag?x=-x:x;
}
template<typename type>
inline void write(type x)
{
x<0?x=-x,putchar('-'):0;
static short Stack[50],top(0);
do Stack[++top]=x%10,x/=10;while(x);
while(top) putchar(Stack[top--]|48);
}
inline int read(double &x){return scanf("%lf",&x);}
inline int read(long double &x){return scanf("%Lf",&x);}
inline void dwrite(const double &x,int y=6,bool flag=1){printf("%.*lf",y,x),flag?putchar(' '):putchar(' ');}
inline void dwrite(const long double &x,int y=6,bool flag=1){printf("%.*Lf",y,x),flag?putchar(' '):putchar(' ');}
inline char read(char &x){do x=getchar();while(isspace(x));return x;}
inline char write(const char &x){return putchar(x);}
inline void read(char *x){static char ch;read(ch);do *(x++)=ch;while(!isspace(ch=getchar())&&~ch);}
inline void write(const char *x){while(*x)putchar(*(x++));}
inline void read(string &x){char ch[1000005]={};read(ch),x=ch;}
inline void write(const string &x){int len=x.length();for(int i=0;i<len;++i)putchar(x[i]);}
template<typename type,typename...T>
inline void read(type &x,T&...y){read(x),read(y...);}
template<typename type,typename...T>
inline void write(const type &x,const T&...y){write(x),putchar(' '),write(y...),sizeof...(y)^1?0:putchar(' ');}
inline __int128 read(){static __int128 x;return read(x);}
template<typename type>
inline type put(type x,bool flag=1){write(x),flag?putchar(' '):putchar(' ');return x;}
}
#ifndef LOCAL
#undef getchar
#undef flush
#undef putchar
#endif
}using namespace IO::usr;
}using namespace ly::IO::usr;
struct Point{
int x,y;
Point operator +(const Point& b)const{return {x+b.x,y+b.y};}
Point operator -(const Point& b)const{return {x-b.x,y-b.y};}
bool operator <(const Point& b)const{
if(x!=b.x)return x<b.x;
return y<b.y;
}
};
const int N=1e5+5;
const int M=1e6+5;
const int inf=1e9+5;
const int mod=1e9+7;
const int bit=50;
//mt19937 sj(chrono::steady_clock::now().time_since_epoch().count());
int B=705;
bitset<10005> b[10005];
int n;
int a[N];
unordered_map<int,int> m,m1,m2;
inline bool cmp(int a,int b){
if(m[a]==m[b]) return a<b;
return m[a]>m[b];
}
int cnt;
bool vis[10005];
inline void solve(){
read(n);
m.clear();
m1.clear();
m2.clear();
cnt=0;
fill0(vis);
for(int i=1;i<=n;++i) b[i].reset();
bool flag=n&1;
flag=n&1;
for(int i=1;i<=n;++i){
read(a[i]);
if(!m1.count(a[i])) m1[a[i]]=++cnt,m2[cnt]=a[i];
a[i]=m1[a[i]];
m[a[i]]++;
if(m[a[i]]>n/2) flag=1;
//cout<<a[i]<<' '<<m[a[i]]<<' '<<i<<' '<<flag<<endl;
}
if(flag||n%2==1){
cout<<-1<<endl;
return;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n/2;++i){
b[i][a[i]]=1;
b[i][a[i+n/2]]=1;
}
int ans=n/2;
for(int i=1;i<=n/2;++i){
if(vis[i]) continue;
for(int j=1;j<=n/2;++j){
if(vis[j]) continue;
if((b[i]&b[j]).count()==0){
vis[j]=1;
--ans;
if((b[i]&b[j]).count()!=0) while(1);
b[i]|=b[j];
if(b[i].count()%2!=0) while(1);
}
}
}
cout<<ans<<endl;
int sum=0;
int num=0;
for(int i=1;i<=n/2;++i){
if(vis[i]) continue;
write(b[i].count());
cout<<' ';
++num;
sum+=b[i].count();
for(int j=1;j<=n;++j){
if(b[i][j]) write(m2[j]),cout<<' ';
}
cout<<endl;
}
}
signed main()
{
int _=1;
read(_);
while(_--) solve();
return (0-0);
}