#include <bits/stdc++.h>
using namespace std;
const int N = 100, S = 100, M = N * S, INF = 1e9;
int c[N][S], s[N], n;
int main() {
  cin >> n;
  int ciel = 0, jiro = 0;
  vector<int> remain;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    for (int j = 0; j < s[i]; ++j) cin >> c[i][j];
    for (int x = 0, y = s[i] - 1; x <= y; ++x, --y) {
      if (x == y)
        remain.push_back(c[i][x]);
      else
        ciel += c[i][x], jiro += c[i][y];
    }
  }
  sort(remain.rbegin(), remain.rend());
  for (unsigned i = 0; i < remain.size(); ++i) {
    if ((i & 1) == 0)
      ciel += remain[i];
    else
      jiro += remain[i];
  }
  cout << ciel << ' ' << jiro;
  return 0;
}
