#include<stdio.h>
#include<string.h>
union payInfo
{
    int full-times alary;
    float part-time hourly rate;
};
struct Employee
{
    char name[50];
    int id;
    int type;
    union payInfo pay;
};
int main()
{
    int n;
    scanf("%d", &n);
    struct Employee emp;
    float total = 0.0f;
    for(int i = 0; i < n; i++)
    {
        scanf("%s %d %d", emp.name, &emp.id, &emp.type);
        if (emp.type == 1)
        {
            scanf("%d",&emp.pay.full-timesalary);
            total += emp.pay.full-timesalary;
        }
        else if (emp.type==2)
        {
            int hours;
            scanf("%f", &emp.pay.part-time hourly rate);
            scanf("%d", &hours);
            total += emp.pay.part-time hourly rate * hours;
        }
        else
        {
            printf("-1");
        }
    }
    printf("%.2f", total);
    return 0;
}