#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  register long long x = 0, f = 0;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
  return f ? -x : x;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const long long N = 201 + 10;
long long n, s, c, ansa, ansb, f;
priority_queue<long long> q;
signed main() {
  n = read();
  for (register long long i = 1; i <= n; ++i) {
    s = read();
    for (register long long j = 1; j <= s; ++j) {
      c = read();
      if ((s & 1) && j == (s + 1) / 2)
        q.push(c);
      else {
        if (j <= s / 2)
          ansa += c;
        else
          ansb += c;
      }
    }
  }
  while (!q.empty()) !f ? ansa += q.top() : ansb += q.top(), q.pop(), f ^= 1;
  cout << ansa << " " << ansb;
  return 0;
}
