#include <bits/stdc++.h>
using namespace std;
int n, x1, x2, maxi, sus, ans1, ans2, a[200];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x1);
    for (int j = 1; j <= x1; j++) {
      scanf("%d", &x2);
      if (j == x1 / 2 + 1 && x1 % 2 == 1)
        sus++, a[sus] = x2;
      else if (j <= x1 / 2)
        ans1 += x2;
      else
        ans2 += x2;
    }
  }
  sort(a + 1, a + sus + 1);
  for (int i = 1; i <= sus; i++) {
    if ((sus + 1 - i) % 2 == 1)
      ans1 += a[i];
    else
      ans2 += a[i];
  }
  printf("%d %d\n", ans1, ans2);
  return 0;
}
