#include <bits/stdc++.h>
using namespace std;
#define br endl
#define pr cout
#define in cin
#define v vector<int>
#define m1 map<int, int>
#define vs vector<string>
#define p pair<int, int>
#define f(n) for (int i = 1; i <= n; i++)
#define f1(n) for (int j = 0; j < n; j++)
#define lli long long int
#define ld long double
#define pb push_back
#define vpi vector<pair<int, int>>
#define vms vector<map<string, int>>
#define vmi vector<map<int, int>>
void solve()
{
int n, positive, negative=0;
cin>>n;
vector<int> vec(n);
vector<int>maximum(n);
int ans[n];
int i=0;
for(auto x: vec)
{
cin>>x;
maximum[i]=x;
i++;
}
// maximum
sort(maximum.begin(),maximum.end() );
reverse(maximum.begin(), maximum.end());
int x=0;
for(int i=0; i<n ; i++)
{
if(maximum[i]>=0)
{
ans[i]=++x;
}
if(maximum[i]<0)
{
for(int j=0; j<i; j++)
{
if(maximum[j]==-1*maximum[i])
{
ans[i]=--x;
}
else
ans[i]= x;
}
}
}
for(int i=0 ; i<n ; i++)
{
pr<<ans[i]<<" ";
}
pr<<br;
// minimum
for(int i=0; i<n; i++)
{
if(maximum[i]>=0)
{
for(int j= i+1; j<n; j++)
{
if(maximum[i]== -1 * maximum[j])
{
negative++;
}
}
}
}
positive=1;
int z=0;
while(z<n){
cout<<positive<<" ";
z++;
if(negative>0)
{
cout<<0<<" ";
--positive;
negative--;
z++;
}
positive++;
}
pr<<br;
}
int main()
{
int t;
in >> t;
bool x = true;
if (x == true)
while (t--)
solve();
else
solve();
}
1279A - New Year Garland | 1279B - Verse For Santa |
202A - LLPS | 978A - Remove Duplicates |
1304A - Two Rabbits | 225A - Dice Tower |
1660D - Maximum Product Strikes Back | 1513A - Array and Peaks |
1251B - Binary Palindromes | 768B - Code For 1 |
363B - Fence | 991B - Getting an A |
246A - Buggy Sorting | 884A - Book Reading |
1180A - Alex and a Rhombus | 445A - DZY Loves Chessboard |
1372A - Omkar and Completion | 159D - Palindrome pairs |
981B - Businessmen Problems | 1668A - Direction Change |
1667B - Optimal Partition | 1668B - Social Distance |
88B - Keyboard | 580B - Kefa and Company |
960A - Check the string | 1220A - Cards |
897A - Scarborough Fair | 1433B - Yet Another Bookshelf |
1283B - Candies Division | 1451B - Non-Substring Subsequence |