#include <bits/stdc++.h>
int arr[101], x[101];
int main() {
  int n;
  scanf("%d", &n);
  int a = 0, b = 0, cnt = 0, sz;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &sz);
    for (int j = 1; j <= sz; ++j) scanf("%d", x + j);
    if (sz & 1) arr[++cnt] = x[(sz >> 1) + 1];
    for (int j = sz >> 1; j >= 1; --j) a += x[j];
    for (int j = (sz >> 1) + 1 + (sz & 1); j <= sz; ++j) b += x[j];
  }
  std::sort(arr + 1, arr + cnt + 1, std::greater<int>());
  for (int i = 1; i <= cnt; i += 2) a += arr[i];
  for (int i = 2; i <= cnt; i += 2) b += arr[i];
  printf("%d %d", a, b);
}
