#include <bits/stdc++.h>
using namespace std;
const int maxN = 105;
int n, s, c[maxN], sum1, sum2;
vector<int> d;
bool cmp(int A, int B) { return A > B; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    for (int j = 1; j <= s; j++) cin >> c[j];
    for (int j = 1; j <= s / 2; j++) sum1 += c[j];
    for (int j = (s + 1) / 2 + 1; j <= s; j++) sum2 += c[j];
    if (s % 2 == 1) d.push_back(c[(s + 1) / 2]);
  }
  sort(d.begin(), d.end(), cmp);
  for (int i = 0; i < d.size(); i++)
    if (i % 2 == 0)
      sum1 += d[i];
    else
      sum2 += d[i];
  cout << sum1 << " " << sum2;
  return 0;
}
