#include <bits/stdc++.h>
using namespace std;
int a[100 + 3], g[100 + 3], n, sl, nn, ansx, ansy;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &sl);
    for (int j = 1; j <= sl; j++) scanf("%d", &g[j]);
    int ll = (sl + 1) >> 1;
    for (int j = 1; j < ll; j++) ansx += g[j];
    for (int j = sl; j > ll; j--) ansy += g[j];
    if (sl & 1)
      a[++nn] = g[ll];
    else
      ansx += g[ll];
  }
  sort(a + 1, a + nn + 1);
  for (int i = nn; i >= 1; i--)
    if ((nn - i) & 1)
      ansy += a[i];
    else
      ansx += a[i];
  printf("%d %d", ansx, ansy);
}
