#include <bits/stdc++.h>
using namespace std;
int p[110];
int m;
priority_queue<int> q;
int main() {
  int i, j, k;
  int n;
  int x;
  bool sw;
  long long ciel = 0, jori = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &m);
    for (j = 0; j < m; j++) {
      scanf("%d", &p[j]);
    }
    if (m & 1) {
      for (j = 0; j < m / 2; j++) ciel += p[j];
      for (j = m / 2 + 1; j < m; j++) jori += p[j];
      q.push(p[m / 2]);
    } else {
      for (j = 0; j < m / 2; j++) ciel += p[j];
      for (j = m / 2; j < m; j++) jori += p[j];
    }
  }
  sw = true;
  while (q.size()) {
    if (sw)
      ciel += q.top();
    else
      jori += q.top();
    sw = !sw;
    q.pop();
  }
  printf("%I64d %I64d", ciel, jori);
  return 0;
}
