#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long readll() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int c[105];
int main() {
  int n = read();
  long long ans = 0, sum = 0;
  vector<int> vec;
  for (int i = 1; i <= n; ++i) {
    int s = read();
    for (int j = 1; j <= s; ++j) c[j] = read(), sum += c[j];
    if (s & 1) vec.push_back(c[s / 2 + 1]);
    for (int j = 1; j <= s / 2; ++j) ans += c[j];
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (int i = 0; i < (int)vec.size(); i += 2) ans += vec[i];
  cout << ans << " " << sum - ans << endl;
  return 0;
}
