#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    long long t = bigmod(p, e / 2, M);
    return (T)((t * t) % M);
  }
  return (T)((long long)bigmod(p, e - 1, M) * (long long)p) % M;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
int ar[101][101], sz[101];
int tmp[101];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long a = 0, b = 0, c, d, e = 0, f = 0, g, h = 0, x, y, z;
  cin >> a;
  for (int i = (0); i < (a); ++i) {
    cin >> sz[i];
    for (int j = (0); j < (sz[i]); ++j) cin >> ar[i][j];
    c = sz[i] / 2;
    for (int j = (0); j < (c); ++j) e += ar[i][j];
    for (int j = sz[i] - 1; j >= sz[i] - c; j--) f += ar[i][j];
    if (sz[i] % 2 == 0)
      tmp[i] = 0;
    else {
      tmp[i] = ar[i][sz[i] - c - 1];
      b++;
    }
  }
  sort(tmp, tmp + a);
  reverse(tmp, tmp + a);
  for (int i = 0; i < a; i++) {
    if (i % 2 == 0)
      e += tmp[i];
    else
      f += tmp[i];
  }
  cout << e << " " << f << endl;
}
