#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<pair<int, int>> p, b;
for(int i = 0; i < n; i++){
int t, x, y;
cin >> t >> x >> y;
if(x < 5){
p.push_back({t, x});
}else {
b.push_back({t, x});
}
}
int ans1, ans2;
ans1 = ans2 = 0;
for(int i = 0; i < p.size(); i++){
ans1 += 100;
if(i != 0 && p[i].first - p[i-1].first <= 10 && p[i].second == p[i-1].second){
ans1 += 50;
}
}for(int i = 0; i < b.size(); i++){
if(i != 0 && b[i].first - b[i-1].first <= 10 && b[i].second == b[i-1].second){
ans2 += 150;
}else {
ans2 += 100;
}
}
// for(auto i: p) cout << i << " ";
cout << ans1 << " " << ans2 << endl;
}