#include <bits/stdc++.h>
using namespace std;
int cards[105][105];
int rec[105];
int main() {
  int n;
  cin >> n;
  int s = 0;
  int Csum = 0;
  int tot = 0;
  for (int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    for (int t = 0; t < tmp; ++t) {
      cin >> cards[i][t];
      tot += cards[i][t];
    }
    for (int t = 0; t < tmp / 2; ++t) {
      Csum += cards[i][t];
    }
    if (tmp % 2) {
      rec[s++] = cards[i][tmp / 2];
    }
  }
  sort(rec, rec + s);
  for (int i = s - 1; i >= 0; i -= 2) {
    Csum += rec[i];
  }
  cout << Csum << ' ' << tot - Csum << endl;
  return 0;
}
