#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int nS;
  cin >> nS;
  vector<int> mid;
  vector<int> ans(2, 0);
  for (int i = 0; i < nS; ++i) {
    int n, val;
    cin >> n;
    for (int j = 0; j < n; ++j) {
      cin >> val;
      if (n % 2 == 1 && j == n / 2)
        mid.push_back(val);
      else if (j < n / 2)
        ans[0] += val;
      else
        ans[1] += val;
    }
  }
  sort(mid.rbegin(), mid.rend());
  for (int i = 0; i < (int)mid.size(); ++i) ans[i & 1] += mid[i];
  cout << ans[0] << " " << ans[1] << endl;
  return 0;
}
