#include <stdio.h>
#include <stdlib.h>
int election(int start, int end, int *ballot, int *sum);
int comparator(const void *, const void *);
//void qsort ( void * base, size_t num, size_t size, int ( * comparator ) ( const void *, const void * ) );
int main()
{
int ballot[20];
int sum[1024 * 1024];
int index;
int t, k, i, j, p;
int allsum;
int rangeless, rangeabove;
int temp, num1, num2, pow;
double halfsum;
scanf("%d", &t);
for(i = 0; i < t; i++) {
scanf("%d", &k);
for(j = 0, allsum = 0; j < k; j++) {
scanf("%d", ballot + j);
allsum += ballot[j];
}
halfsum = allsum / 2.0;
//判断是否有独裁
for(j = 0; j < k; j++) {
if(ballot[j] > halfsum) break;
}
if(j != k) {
printf("It's unfair!\n");
continue;
}
//计算权数
for(j = 0; j < k; j++) {
rangeless = halfsum - ballot[j] + 1;
rangeabove = (halfsum - (int)halfsum)*2 + (int)halfsum - 1;
temp = ballot[j];
ballot[j] = ballot[k - 1];
index = election(0, k-2, ballot, sum);
qsort(sum, index, sizeof(int), comparator);
//printf("\n%d %d\n", rangeless, rangeabove);
/*for(p = 0; p < index; p++) {
printf("%d ", sum[p]);
}*/
num1 = binfind(sum, index, rangeless);
//printf("\n%d\n", num1);
if(sum[num1] < rangeless) {
while(sum[num1++] < rangeless && num1 < index);
num1--;
} else {
while(sum[num1--] >= rangeless && num1 >= 0);
num1 = (num1 == -1) ? 0 : num1+2;
}
num2 = binfind(sum, index, rangeabove);
if(sum[num2] <= rangeabove) {
while(sum[num2++] <= rangeabove && num1 < index);
num2 = (num2 == index) ? num2-1 : num2-2;
} else {
while(sum[num2--] > rangeabove && num2 >=0);
num2++;
}
//printf("\n%d %d\n", num2, num1);
printf("%d ", num2 - num1 +1);
ballot[j] = temp;
}
printf("\n");
}
return 0;
}
int election(int start, int end, int *ballot, int *sum)
{
int index; // 下一个要写的数的位置
if(start == end) {
sum[0] = 0;
sum[1] = ballot[end];
index = 2;
return index;
}
//start++;
index = election(start+1, end, ballot, sum);
int i;
for(i = 0; i < index; i++) {
sum[index + i] = sum[i] + ballot[start];
}
return index * 2;
}
int comparator(const void *a, const void *b)
{
if(*(int *)a < *(int *)b)
return -1;
else if(*(int *)a == *(int *)b)
return 0;
else
return 1;
}
int binfind(int val[] , int num , int value)
{
int start = 0;
int end = num - 1;
int mid = (start + end)/2;
while(val[mid] != value && start < end) {
if (val[mid] > value) {
end = mid - 1;
} else if (val[mid] < value) {
start = mid + 1;
}
mid = ( start + end )/2;
}
return mid;
}