#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long inf = numeric_limits<long long>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
template <typename T>
inline bool mineq(T& a, T b) {
  return (a > b) ? (a = b, 1) : 0;
}
template <typename T>
inline bool maxeq(T& a, T b) {
  return (a < b) ? (a = b, 1) : 0;
}
inline void solve(), read();
const string file = "";
int main() {
  if (file != "") {
    freopen((file + ".in").c_str(), "r", stdin);
    freopen((file + ".out").c_str(), "w", stdout);
  }
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  read();
  solve();
  return 0;
}
long long n;
long long s1 = 0, s2 = 0;
vector<long long> a;
inline void solve() {
  for (long long i = 0; i < n; i++) {
    long long k;
    cin >> k;
    vector<long long> s(k);
    for (long long j = 0; j < k; j++) {
      cin >> s[j];
    }
    if (k % 2 == 0) {
      for (long long j = 0; j < k / 2; j++) {
        s1 += s[j];
      }
      for (long long j = k / 2; j < k; j++) {
        s2 += s[j];
      }
    } else {
      for (long long j = 0; j < k / 2; j++) {
        s1 += s[j];
      }
      for (long long j = k / 2 + 1; j < k; j++) {
        s2 += s[j];
      }
      a.push_back(s[k / 2]);
    }
  }
  sort((a).begin(), (a).end(), greater<long long>());
  for (long long i = 0; i < (long long)((a).size()); i++) {
    if (i % 2 == 0) {
      s1 += a[i];
    } else {
      s2 += a[i];
    }
  }
  cout << s1 << " " << s2 << "\n";
}
inline void read() { cin >> n; }
