#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N], s[N], o1, o2, top, n;
inline void fr(int &num) {
  num = 0;
  char c = getchar();
  int p = 1;
  while (c < '0' || c > '9') c == '-' ? p = -1, c = getchar() : c = getchar();
  while (c >= '0' && c <= '9') num = num * 10 + c - '0', c = getchar();
  num *= p;
}
inline bool cmp(register int x, register int y) { return x > y; }
int main() {
  fr(n);
  for (register int i = 1; i <= n; ++i) {
    fr(a[0]);
    for (register int j = 1; j <= a[0]; ++j) fr(a[j]);
    if (a[0] & 1) s[++top] = a[a[0] / 2 + 1], a[a[0] / 2 + 1] = 0;
    for (register int j = 1, sz = a[0] >> 1; j <= sz; ++j) o1 += a[j];
    for (register int j = (a[0] >> 1) + 1; j <= a[0]; ++j) o2 += a[j];
  }
  sort(s + 1, s + 1 + top, cmp);
  for (register int i = 1; i <= top; ++i) i & 1 ? o1 += s[i] : o2 += s[i];
  printf("%d %d", o1, o2);
  return 0;
}
