#include <bits/stdc++.h>
using namespace std;
inline void R(int &x) {
  char ch = getchar();
  x = 0;
  for (; ch < '0'; ch = getchar())
    ;
  for (; ch >= '0'; ch = getchar()) x = x * 10 + ch - '0';
}
const int N = 105;
int n, cnt[N], a[N][N];
int main() {
  R(n);
  int m, s1 = 0, s2 = 0;
  vector<int> rem;
  for (int i = 1; i <= n; ++i) {
    R(cnt[i]);
    for (int j = 1; j <= cnt[i]; ++j) R(a[i][j]);
    m = cnt[i] / 2;
    for (int j = 1; j <= m; ++j) s1 += a[i][j], s2 += a[i][cnt[i] + 1 - j];
    if (cnt[i] & 1) rem.push_back(a[i][m + 1]);
  }
  sort(rem.begin(), rem.end());
  reverse(rem.begin(), rem.end());
  for (int i = 0; i < rem.size(); ++i)
    if (i & 1)
      s2 += rem[i];
    else
      s1 += rem[i];
  printf("%d %d\n", s1, s2);
  return 0;
}
