#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
bool cmp(int a, int b) { return a > b; }
int main() {
  int n, m, a[maxn];
  int sum1, sum2;
  vector<int> v;
  while (~scanf("%d", &n)) {
    v.clear();
    memset(a, 0, sizeof(a));
    sum1 = sum2 = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &m);
      int mid = m / 2;
      for (int j = 0; j < m; j++) {
        scanf("%d", &a[j]);
        if (j < mid)
          sum1 += a[j];
        else
          sum2 += a[j];
      }
      if (m % 2) {
        sum2 -= a[mid];
        v.push_back(a[mid]);
      }
    }
    sort(v.begin(), v.end(), cmp);
    for (int i = 0; i < v.size(); i++) {
      if (i % 2)
        sum2 += v[i];
      else
        sum1 += v[i];
    }
    printf("%d %d\n", sum1, sum2);
  }
  return 0;
}
