#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 union SalaryDetails {
     int fullTimeSalary;
     float partTimeSalary;
 };
 struct Employee{
     char name[50];
     int id;
     int type;
     union SalaryDetails details;
 };
 int main (){
     int n;
     if(scanf("%d",&n) !=1)return 1;
     
     if(n<0){
         printf("-1\n");
         return 0;
     }
     struct Employee *employees=(struct Employee*)malloc(n*sizeof(struct Employee));
     if(employees==NULL){
         fprintf(stderr,"Memoery allocation failed\n");
         return 1;
     }
     float totalSalaries=0.0;
     for(int i=0;i<n;i++){
        if(scanf("%s %d %d",employees[i].name,&employees[i].id,&employees[i].type)!=3){
            free(employees);
            return 1;
        }
        if(employees[i].type==1){
            if(scanf("%d",&employees[i].details.fullTimeSalary)!=1){
               free(employees);
                return 1;
            }
            totalSalaries+=employees[i].details.fullTimeSalary;
        }
        else if(employees[i].type==2){
        if(scanf("%f",&employees[i].details.partTimeHourlyRate)!=1){
            free(employees);
            return 1;
        }
            totalSalaries+=employees[i].details.partTimeHourlyRate*40.0;
        }
     }
     printf("%.2f\n",totalSalaries);
     return 0;
 }