#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int s[N];
int ma[N][N];
int main() {
  int n;
  vector<int> v;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    for (int j = 0; j < s[i]; ++j) {
      cin >> ma[i][j];
    }
  }
  int r1 = 0, r2 = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < s[i] / 2; ++j) {
      r1 += ma[i][j];
      r2 += ma[i][s[i] - 1 - j];
    }
    if (s[i] % 2) v.push_back(ma[i][s[i] / 2]);
  }
  sort(v.begin(), v.end(), greater<int>());
  for (int i = 0; i < v.size(); ++i) {
    if (i % 2)
      r2 += v[i];
    else
      r1 += v[i];
  }
  cout << r1 << " " << r2 << endl;
  return 0;
}
