#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
long long n;
long long s[111];
long long c[111][111];
int main() {
  cin >> n;
  long long a = 0;
  long long b = 0;
  long long m[111];
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    if (s[i] % 2 == 0) m[i] = 0;
    for (int j = 1; j <= s[i]; j++) {
      cin >> c[i][j];
      if (j <= s[i] / 2)
        a += c[i][j];
      else if ((s[i] % 2 == 1) && (j == (s[i] + 1) / 2))
        m[i] = c[i][j];
      else
        b += c[i][j];
    }
  }
  sort(m + 1, m + n + 1);
  reverse(m + 1, m + n + 1);
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1)
      a += m[i];
    else
      b += m[i];
  }
  cout << a << " " << b << endl;
  return 0;
}
