#include <bits/stdc++.h>   using namespace std;   int i, t, n, ciel, jiro, aux, a[10005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     for (cin >> t; t; --t) {       cin >> n;       for (i = 1; i <= n; ++i) {         cin >> aux;         if (n & 1)           if (i == n / 2 + 1)             a[++a[0]] = aux;           else if (i <= n / 2)             ciel += aux;           else             jiro += aux;         else if (i <= n / 2)           ciel += aux;         else           jiro += aux;       }     }     sort(a + 1, a + a[0] + 1);     for (i = a[0]; i; --i)       if ((a[0] - i) & 1)         jiro += a[i];       else         ciel += a[i];     cout << ciel <<     << jiro <<   n ;     return 0;   }   