#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
vector<int> all;
int a[105];
int main() {
  int n, i, sum1 = 0, sum = 0, j, x;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &x);
    for (j = 1; j <= x; ++j) {
      scanf("%d", &a[j]);
    }
    for (j = 1; j * 2 <= x; ++j) sum += a[j];
    if (x & 1) {
      all.push_back(a[(x + 1) / 2]);
      ++j;
    }
    for (; j <= x; ++j) sum1 += a[j];
  }
  sort(all.begin(), all.end());
  reverse(all.begin(), all.end());
  for (i = 0; i < all.size(); ++i) {
    if (i & 1)
      sum1 += all[i];
    else
      sum += all[i];
  }
  printf("%d %d\n", sum, sum1);
  return 0;
}
