#include <bits/stdc++.h>
using namespace std;
int sum[110][110], a[110][110], ans[110];
bool cmp(int a, int b) { return a > b; }
int main() {
  int i, j, n, m;
  scanf("%d", &n);
  int r = 0;
  int C = 0, J = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &m);
    scanf("%d", &a[i][0]);
    sum[i][0] = a[i][0];
    for (j = 1; j < m; j++) {
      scanf("%d", &a[i][j]);
      sum[i][j] = sum[i][j - 1] + a[i][j];
    }
    if (m & 1) {
      ans[r++] = a[i][m / 2];
      J += sum[i][m - 1] - sum[i][m / 2];
    } else
      J += sum[i][m - 1] - sum[i][m / 2 - 1];
    C += sum[i][m / 2 - 1];
  }
  sort(ans, ans + r, cmp);
  for (i = 0; i < r; i++)
    if ((i & 1) == 0)
      C += ans[i];
    else
      J += ans[i];
  printf("%d %d\n", C, J);
  return 0;
}
