#include <bits/stdc++.h>
using namespace std;
int n, m, A, B;
priority_queue<int> Q;
signed main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &m);
    for (int j = 1, x; j <= m; j++) {
      scanf("%d", &x);
      if (m & 1 && j == (m + 1) >> 1)
        Q.push(x);
      else {
        if (j <= m >> 1)
          A += x;
        else
          B += x;
      }
    }
  }
  int p = 1;
  while (!Q.empty()) p ? A += Q.top() : B += Q.top(), Q.pop(), p ^= 1;
  printf("%d %d", A, B);
  return 0;
}
