#include <bits/stdc++.h>
using namespace std;
const int N = 111;
int c[N][N];
int r[N];
int n;
int main() {
  ios::sync_with_stdio(false);
  cout.precision(10);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> r[i];
    for (int j = 1; j <= r[i]; j++) {
      cin >> c[i][j];
    }
  }
  priority_queue<int> q;
  int aans = 0, bans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= r[i]; j++) {
      if (r[i] & 1 && j == r[i] + 1 >> 1) {
        q.push(c[i][j]);
      } else if (j <= r[i] >> 1) {
        aans += c[i][j];
      } else {
        bans += c[i][j];
      }
    }
  }
  bool turn = true;
  while (q.size()) {
    if (turn) {
      aans += q.top();
    } else {
      bans += q.top();
    }
    q.pop();
    turn = !turn;
  }
  cout << aans << " " << bans << "\n";
  return 0;
}
