#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<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);
}else {
b.push_back(t);
}
}sort(p.begin(), p.end());
sort(b.begin(), b.end());
int ans1, ans2;
ans1 = ans2 = 0;
for(int i = 0; i < p.size(); i++){
if(i != 0 && p[i] - p[i-1] <= 10){
ans1 += 150;
}else {
ans1 += 100;
}
}for(int i = 0; i < b.size(); i++){
if(i != 0 && b[i] - b[i-1] <= 10){
ans2 += 150;
}else {
ans2 += 100;
}
}
// for(auto i: p) cout << i << " ";
cout << ans1 << " " << ans2 << endl;
}