#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int main() {
  int n, a[110][110], b[110], c[110];
  cin >> n;
  int tot = 0;
  int ansx = 0, ansy = 0;
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    for (int j = 1; j <= b[i]; j++) {
      cin >> a[i][j];
    }
    int x = 1, y = b[i];
    while (x + 1 <= y) {
      ansx += a[i][x++];
      ansy += a[i][y--];
    }
    if (b[i] & 1) c[++tot] = a[i][(b[i] + 1) / 2];
  }
  sort(c + 1, c + tot + 1);
  for (int i = 1; i <= tot; i++)
    if (i & 1)
      ansx += c[tot - i + 1];
    else
      ansy += c[tot - i + 1];
  cout << ansx << " " << ansy << endl;
  return 0;
}
