#include<stdio.h>
union Salary{
    int full;
    float part;
};
struct Employee{
    char name[50];
    int id,type;
    union Salary sal;
};
int main() {
    int n;
    scanf("%d",&n);
    if(n < 0){
        printf("-1");
        return 0;
    }
    struct Employee;
    float total=0;
    for(int i=0;i<n;i++){
        scanf("%s",&e.name);
        scanf("%d%d",&e.id,&e.type);
        if(e.type == 1){
            scanf("%d",&e.sal.full);
            total+=e.sal.full;
        }else{
            scanf("%f",&e.sal.part);
            total+=e.salpart;
        }
    }
    printf("%2.f",total);
    return 0;
}