#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l = 0, r = 0, k, num[105];
  vector<int> P;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> num[j];
      if (j <= k / 2 - 1) l += num[j];
      if (j > (k + 1) / 2 - 1) r += num[j];
    }
    if (k & 1) P.push_back(num[k / 2]);
  }
  sort(P.begin(), P.end());
  int len = P.size();
  for (int i = len - 1; i >= 0; i--) {
    if ((len - i) & 1)
      l += P[i];
    else
      r += P[i];
  }
  cout << l << " " << r << endl;
}
