#include <bits/stdc++.h>
using namespace std;
int n, s[111], a[111][111], z[111], nz;
int main() {
  ios ::sync_with_stdio(false);
  while (cin >> n) {
    int left = 0, right = 0;
    nz = 0;
    for (int i = (1), _b = (n); i <= _b; i++) {
      cin >> s[i];
      for (int j = (1), _b = (s[i]); j <= _b; j++) cin >> a[i][j];
      for (int u = 1, v = s[i]; u < v; ++u, --v) {
        left += a[i][u];
        right += a[i][v];
      }
      if (s[i] % 2 == 1) {
        z[++nz] = a[i][s[i] / 2 + 1];
      }
    }
    sort(z + 1, z + nz + 1);
    int turn = 1;
    for (int i = (nz), _b = (1); i >= _b; i--) {
      if (turn % 2 == 1)
        left += z[i];
      else
        right += z[i];
      ++turn;
    }
    cout << left << ' ' << right << endl;
  }
  return 0;
}
