#include <bits/stdc++.h>
using namespace std;
int c[120][120], ct[120], n;
int ccc[120], Ciel, Jiro, cnt;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", ct + i);
    int p1 = ct[i] / 2 - 1, p2 = ct[i] - ct[i] / 2;
    for (int j = 0; j < ct[i]; j++) {
      scanf("%d", &c[i][j]);
      if (j <= p1)
        Ciel += c[i][j];
      else if (j >= p2)
        Jiro += c[i][j];
      else
        ccc[cnt++] = c[i][j];
    }
  }
  sort(ccc, ccc + cnt);
  for (int i = cnt - 1; i >= 0; i--) {
    if ((cnt - i) % 2)
      Ciel += ccc[i];
    else
      Jiro += ccc[i];
  }
  printf("%d %d\n", Ciel, Jiro);
  return 0;
}
