#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, a[N], s[N], js;
int p, q;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int m;
    scanf("%d", &m);
    int t = m >> 1;
    for (int j = 0; j <= m - 1; ++j) {
      scanf("%d", &a[j]);
      if (j < t)
        p += a[j];
      else
        q += a[j];
    }
    if (m & 1) q -= a[t], s[++js] = a[t];
  }
  sort(s + 1, s + js + 1, greater<int>());
  for (int i = 1; i <= js; ++i)
    if (i & 1)
      p += s[i];
    else
      q += s[i];
  printf("%d %d\n", p, q);
  return 0;
}
