// by hBarcellos 2022
#include <stdio.h>
#include <stdlib.h>
#define N 2500
int partition(int a[], int start, int end)
{
int pivot = a[end];
int pIndex = start;
int temp;
for (int i = start; i < end; i++) {
if (a[i] <= pivot) {
temp = a[i];
a[i] = a[pIndex];
a[pIndex] = temp;
pIndex++;
}
}
temp = a[end];
a[end] = a[pIndex];
a[pIndex] = temp;
return pIndex;
}
void quicksort(int a[], int start, int end)
{
if (start >= end) {
return;
}
int pivot = partition(a, start, end);
quicksort(a, start, pivot - 1);
quicksort(a, pivot + 1, end);
}
int va[N], vb[N], vc[N], vd[N];
int main(int argc, char *argv[])
{
int n, i,j,k,l;
int soma;
unsigned int total = 0;
scanf("%d", &n);
printf("--------\n");
for (i = 0; i < n; i++) {
scanf("%d %d %d %d", &va[i], &vb[i], &vc[i], &vd[i]);
// printf("%d %d %d %d\n", va[i], vb[i], vc[i], vd[i]);
}
quicksort(va,0,n);
quicksort(vb,0,n);
quicksort(vc,0,n);
quicksort(vd,0,n);
for (i = 0; i < n; i++) {
printf("%d %d %d %d\n", va[i], vb[i], vc[i], vd[i]);
}
printf("--------\n");
for (i=0;i<n;i++) {
printf("\n==Status = [%d de %d]",i,n);
for (j=0;j<n;j++) {
for (k=0;k<n;k++) {
for (l=0;l<n;l++) {
soma=va[i]+vb[j]+vc[k]+vd[l];
if (soma>0) break;
if (soma==0) {
total++;
//printf("%d %d %d %d\n",va[i],vb[j],vc[k],vd[l]);
}
}}}}
printf("Total de combinacoes q deram ZERO: %u\n", total);
return 0;
}