#include<stdio.h>
#include<malloc.h>
union Salary {
    int fullTimeSalary;
    float partTimeRate,employees;
};
struct Employee {
    char name[1000];
    int id;
    int type;
    union Salary payment ;
};
int main(){
    int n;
    scanf("%d",&n);
    if(n<0){
        printf("-1");
        return 0;
    }
    struct Employee *employees=malloc(n*sizeof(struct Employee));
    double totalSalary= 0.0;
    for(int i=0;i<n;i++){
        scanf("%s %d %d",employees[i].name, &employees[i].id, &employees[i].type);
        if(employees[i].type==1){
            scanf("%d ",&employees[i].payment.fullTimeSalary);
            totalSalary+=employees[i].payment.fullTimeSalary;
        }
        else if(employees[i].type==2)
        {
            scanf("%f ",&employees[i].payment.fullTimeSalary);
            totalSalary+=employees[i].payment.partTimeRate*40;
        }
    }
    printf("%.2f", totalSalary);
    return 0;
}