#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long a = 0, b = 0;
  int k[105], kp = 0;
  for (int i = 0; i < n; i++) {
    int m;
    scanf("%d", &m);
    int c[105];
    for (int i = 0; i < m; i++) scanf("%d", &c[i]);
    if (m & 1) {
      k[kp++] = c[m / 2];
      for (int i = 0; i < m / 2; i++) a += c[i];
      for (int i = (m / 2) + 1; i < m; i++) b += c[i];
    } else {
      for (int i = 0; i < m / 2; i++) a += c[i];
      for (int i = m / 2; i < m; i++) b += c[i];
    }
  }
  sort(k, k + kp);
  for (int i = kp - 1; i >= 0; i -= 2) a += k[i];
  for (int i = kp - 2; i >= 0; i -= 2) b += k[i];
  printf("%lld %lld\n", a, b);
}
