#include <bits/stdc++.h>
using namespace std;
const int MAX = 101;
int odd[MAX], sz, n;
int main() {
  scanf("%d", &n);
  int sum[2]{};
  for (int i = 0, s; i < n; ++i) {
    scanf("%d", &s);
    for (int j = 1, x; j <= s; ++j) {
      scanf("%d", &x);
      if (j * 2 == s + 1)
        odd[++sz] = x;
      else
        sum[j * 2 <= s] += x;
    }
  }
  sort(odd + 1, odd + sz + 1);
  for (int i = 1; i <= sz; ++i) sum[i & 1] += odd[sz - i + 1];
  printf("%d %d\n", sum[1], sum[0]);
  return 0;
}
