#include<stdio.h>

#define FULL_TIME 1
#define PART_TIME 2

struct Employee
{
    char name[50];
    int id;
    int type;
    
    union Salary
    {
        int full_time;
        float part_time;
    }sal;
};

void inputEmployee(struct Employee*e)
{
    scanf("%s %d %d", e->name, &e->id,&e->type );
    
    if(e->type == FULL_TIME)
    {
      scanf("%d", &e->sal.full_time );  
    }
    else if(e->type == PART_TIME)
    {
        scanf("%f", &e->sal.part_time ); 
    }
}

float calculateTotalSalary(int n)
{
    float total =0;
    
    for(int i=0;i<n;i++)
    {
        struct Employee e;
        inputEmployee(&e);
        
        if(e.type == FULL_TIME)
        {
            total += e.sal.full_time;
        }
        else if(e.type == PART_TIME)
        {
            total += e.sal.part_time;
        }
        else
        {
            printf("Invalid employee type.\n");
        }
    
    }
    return total;
}

int main()
{
    int n;
    scanf("%d",&n);
    
    if(n<0)
    {
        printf("-1\n");
        return 0;
    }
    
    float totalsalary = calculateTotalSalary(n);
    printf("%.2f",totalsalary);
}
return 0;
}