#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n;
  cin >> n;
  vector<vector<long long> > w(n);
  for (int i = 0; i < int(n); ++i) {
    unsigned long long buf;
    cin >> buf;
    w[i] = vector<long long>(buf);
    for (int j = 0; j < int(buf); ++j) {
      cin >> w[i][j];
    }
  }
  unsigned long long cdj = 0;
  unsigned long long csi = 0;
  vector<long long> cs(n);
  for (int i = 0; i < int(n); ++i) {
    for (int j = 0; j < int(w[i].size() / 2); ++j) {
      csi += w[i][j];
    }
    if (w[i].size() % 2 == 1) {
      cs[i] = w[i][w[i].size() / 2];
      for (unsigned long long j = w[i].size() / 2 + 1; j < w[i].size(); ++j) {
        cdj += w[i][j];
      }
    } else {
      cs[i] = 0;
      for (unsigned long long j = w[i].size() / 2; j < w[i].size(); ++j) {
        cdj += w[i][j];
      }
    }
  }
  sort(cs.begin(), cs.end());
  reverse(cs.begin(), cs.end());
  bool step = 0;
  for (int i = 0; i < int(n); ++i) {
    if (step == 0) {
      csi += cs[i];
    } else {
      cdj += cs[i];
    }
    step = !step;
  }
  cout << csi << ' ' << cdj << endl;
}
