#include <bits/stdc++.h>
using namespace std;
int n, ans1, ans2, nr, x;
vector<int> v;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> nr;
    for (int j = 1; j <= nr; ++j) {
      cin >> x;
      if (nr % 2 == 1 && j == (nr + 1) / 2) {
        v.push_back(-x);
        continue;
      }
      if (j <= nr / 2)
        ans1 += x;
      else
        ans2 += x;
    }
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    if (i % 2 == 0)
      ans1 -= v[i];
    else
      ans2 -= v[i];
  }
  cout << ans1 << " " << ans2;
  return 0;
}
