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