#include <bits/stdc++.h>
using namespace std;
const int DEBUG = 0;
namespace defs {
template <class Type>
Type read() {
  Type aa;
  int bb = 1, ch;
  while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
    ;
  ch == '-' ? aa = 0, bb = -1 : aa = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9') aa = aa * 10 + ch - '0';
  return bb == 1 ? aa : -aa;
}
const unsigned int rand_x = 11309;
const unsigned int rand_y = 1000000019;
unsigned int rand_cur;
unsigned int rand_int() { return rand_cur = rand_cur * rand_x + rand_y; }
const int inf = 1071026353;
const int mod = 1000000007;
const int modx = 998244353;
}  // namespace defs
namespace lightningwork {
int (*read)() = defs::read<int>;
int n, t[110];
int num[110][110];
int s1, s2;
int que[110], tot;
void work() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    t[i] = read();
    for (int j = 1; j <= t[i]; ++j) {
      num[i][j] = read();
    }
    int mid = t[i] / 2;
    for (int j = 1; j <= mid; ++j) {
      s1 += num[i][j];
      s2 += num[i][t[i] + 1 - j];
    }
    if (t[i] & 1) {
      que[++tot] = num[i][mid + 1];
    }
  }
  sort(que + 1, que + tot + 1);
  for (int i = 1; i <= tot; ++i) {
    if (i & 1)
      s1 += que[tot + 1 - i];
    else
      s2 += que[tot + 1 - i];
  }
  printf("%d %d\n", s1, s2);
}
}  // namespace lightningwork
int main() {
  if (0)
    freopen(
        "work"
        ".in",
        "r", stdin),
        freopen(
            "work"
            ".out",
            "w", stdout);
  lightningwork::work();
  if (0) fclose(stdin), fclose(stdout);
  return 0;
}
