#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
int main() {
  int n;
  cin >> n;
  int a[111][111] = {0};
  int ans1 = 0, ans2 = 0;
  vector<int> mids;
  for (int i = 1; i <= n; i++) {
    cin >> a[i][0];
    for (int j = 1; j <= a[i][0]; j++) {
      cin >> a[i][j];
      if (a[i][0] % 2 == 0) {
        if (j <= a[i][0] / 2) {
          ans1 += a[i][j];
        } else
          ans2 += a[i][j];
      } else {
        if (j < a[i][0] / 2 + 1) {
          ans1 += a[i][j];
        } else if (j == a[i][0] / 2 + 1 || a[i][0] == 1) {
          mids.push_back(a[i][j]);
        } else
          ans2 += a[i][j];
      }
    }
  }
  sort(mids.begin(), mids.end());
  reverse(mids.begin(), mids.end());
  for (int i = 0; i < mids.size(); i++) {
    if (i % 2 == 0) {
      ans1 += mids[i];
    } else
      ans2 += mids[i];
  }
  cout << ans1 << " " << ans2;
  return 0;
}
