#include <bits/stdc++.h>
using namespace std;
int a[10005], b[10005], c, d, e, f, g, h, i, j, k, l, m, n;
inline bool cmp(const int &a, const int &b) { return a > b; }
int main() {
  scanf("%d", &n);
  for (l = 1; l <= n; l++) {
    scanf("%d", &k);
    for (i = 1; i <= k; i++) scanf("%d", &a[i]);
    for (i = 1; i <= k / 2; i++) h += a[i];
    for (i = (k + 1) / 2 + 1; i <= k; i++) g += a[i];
    if (k & 1) b[++m] = a[k / 2 + 1];
  }
  sort(b + 1, b + 1 + m, cmp);
  for (i = 1; i <= m; i++)
    if (i & 1)
      h += b[i];
    else
      g += b[i];
  printf("%d %d", h, g);
  return 0;
}
