#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool elem(set<T> st, T val) {
  return (st.find(val) != st.end());
}
template <typename T>
void printv(vector<T> vt) {
  if (vt.size() == 0) return;
  for (int i = 0; i < (int)vt.size() - 1; ++i) cout << vt[i] << " ";
  cout << vt[vt.size() - 1] << endl;
}
vector<vector<int> > p;
int main(void) {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < (int)n; ++i) {
    int m;
    cin >> m;
    vector<int> a(m);
    for (int j = 0; j < (int)m; ++j) cin >> a[j];
    p.push_back(a);
  }
  int sum = 0;
  for (int i = 0; i < (int)n; ++i)
    for (int j = 0; j < (int)p[i].size(); ++j) sum += p[i][j];
  int sc = 0;
  vector<int> rem;
  for (int i = 0; i < (int)n; ++i) {
    for (int j = 0; j < (int)p[i].size() / 2; ++j) sc += p[i][j];
    if (p[i].size() % 2 == 1) rem.push_back(p[i][p[i].size() / 2]);
  }
  sort(rem.begin(), rem.end(), greater<int>());
  for (int i = 0; i < (int)rem.size(); i += 2) sc += rem[i];
  cout << sc << " " << sum - sc << endl;
  return 0;
}
