#include <bits/stdc++.h>
using namespace std;
const int N = 200;
int a[N][N];
int n, sum1, sum2;
vector<int> V;
int main() {
  cin >> n;
  int m, x;
  for (int i = 1; i <= n; ++i) {
    cin >> m;
    for (int j = 1; j <= m; ++j) {
      cin >> x;
      if (j == m / 2 + 1 and (m & 1) == 1)
        V.push_back(x);
      else if (j <= m / 2)
        sum1 += x;
      else
        sum2 += x;
    }
  }
  sort(V.begin(), V.end());
  for (int i = V.size() - 1; i >= 0; --i) {
    if (((V.size() - i + 1) & 1) == 1)
      sum2 += V[i];
    else
      sum1 += V[i];
  }
  cout << sum1 << " " << sum2;
}
