#include <bits/stdc++.h>
using namespace std;
int A[110];
int n, m, s1, s2;
void enter() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int ni;
    cin >> ni;
    for (int j = 1; j <= ni; ++j) {
      int a;
      cin >> a;
      if (j * 2 - 1 == ni)
        A[++m] = a;
      else
        (j * 2 <= ni ? s1 : s2) += a;
    }
  }
}
void solve() {
  sort(A + 1, A + m + 1);
  int k = 0;
  for (int i = m; i > 0; --i) {
    k ^= 1;
    (k ? s1 : s2) += A[i];
  }
  cout << s1 << " " << s2;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  if (ifstream("388C.inp")) cin.rdbuf((new ifstream("388C.inp"))->rdbuf());
  enter();
  solve();
}
