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