#include <bits/stdc++.h>
using namespace std;
int n;
int s[105];
int c[105][105];
int ans[2];
vector<int> mid;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < s[i]; j++) {
      cin >> c[i][j];
      if (j < s[i] / 2) {
        ans[0] += c[i][j];
      } else {
        if (s[i] % 2 == 1 && j == s[i] / 2) {
          mid.push_back(c[i][j]);
        } else {
          ans[1] += c[i][j];
        }
      }
    }
  }
  sort(mid.begin(), mid.end());
  reverse(mid.begin(), mid.end());
  for (int i = 0; i < mid.size(); i++) {
    ans[i % 2] += mid[i];
  }
  cout << ans[0] << " " << ans[1] << endl;
  return 0;
}
