#include <bits/stdc++.h>
using namespace std;
const int N = 105;
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + c - '0';
  x *= f;
}
int n;
int cnt[N];
int a[N][N];
int A[N], B[N];
int L[N], R[N];
int val[N];
int ans1, ans2;
bool cmp(int x, int y) { return x > y; }
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(cnt[i]);
    for (int j = 1; j <= cnt[i]; j++) read(a[i][j]);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= cnt[i] / 2; j++) ans1 += a[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = cnt[i] - cnt[i] / 2 + 1; j <= cnt[i]; j++) ans2 += a[i][j];
  int tot = 0;
  for (int i = 1; i <= n; i++)
    if (cnt[i] & 1) val[++tot] = a[i][cnt[i] / 2 + 1];
  sort(val + 1, val + tot + 1, cmp);
  for (int i = 1; i <= tot; i++)
    if (i & 1)
      ans1 += val[i];
    else
      ans2 += val[i];
  printf("%d %d\n", ans1, ans2);
  return 0;
}
