#include <bits/stdc++.h>
using namespace std;
int t[105], a[105], sum1, sum2, n, m, tot;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) {
      int t;
      scanf("%d", &t);
      if ((m & 1) && i == m / 2)
        a[tot++] = t;
      else if (i < m / 2)
        sum1 += t;
      else
        sum2 += t;
    }
  }
  sort(a, a + tot, greater<int>());
  for (int i = 0; i < tot; ++i)
    if (i & 1)
      sum2 += a[i];
    else
      sum1 += a[i];
  printf("%d %d", sum1, sum2);
}
