#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
struct Niz {
  int val, sum;
  Niz() {}
  Niz(int _a, int _b) {
    val = _a;
    sum = _b;
  }
} niz[maxn];
bool cmp1(const Niz &a, const Niz &b) { return a.val > b.val; }
int main() {
  int n, z = 0, d = 0, a = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int s, sum = 0, sum1 = 0;
    scanf("%d", &s);
    for (int j = 1; j <= s; j++) {
      int x;
      scanf("%d", &x);
      z += x;
      if (j <= s >> 1) sum1 += x;
      if (j == (s >> 1) + (s & 1)) sum = x;
    }
    if (s & 1)
      niz[++d] = Niz(sum, sum1);
    else
      a += sum1;
  }
  sort(niz + 1, niz + d + 1, cmp1);
  for (int i = 1; i <= d; i++)
    if (i & 1)
      a += niz[i].sum + niz[i].val;
    else
      a += niz[i].sum;
  printf("%d %d\n", a, z - a);
  return 0;
}
