#include <bits/stdc++.h>
using namespace std;
int size[110];
int p[110][110];
vector<int> v;
int main() {
  int n, a = 0, b = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &size[i]);
    for (int j = 0; j < size[i]; j++) {
      scanf("%d", &p[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    if (size[i] % 2 == 1) {
      for (int j = 0; j < size[i] / 2; j++) {
        a += p[i][j];
      }
      v.push_back(p[i][size[i] / 2]);
      for (int j = size[i] / 2 + 1; j < size[i]; j++) {
        b += p[i][j];
      }
    } else {
      for (int j = 0; j < size[i] / 2; j++) {
        a += p[i][j];
      }
      for (int j = size[i] / 2; j < size[i]; j++) {
        b += p[i][j];
      }
    }
  }
  sort(v.rbegin(), v.rend());
  for (int i = 0; i < (int)v.size(); i++) {
    if (i % 2 == 0) {
      a += v[i];
    } else
      b += v[i];
  }
  printf("%d %d", a, b);
  return 0;
}
