# Sarah Buchanan
# 6/29/2012
# Solution to Heavy Averages assignment
# Calculates student's final grades based on the weight of each grade.

def main():
    # Open file
    myFile = open("heavy.txt", "r")

    # Read in the number of students
    numStudents = int(myFile.readline())

    # Read in the 5 percentages which are the weights of each grade
    percentages = myFile.readline().split()

    # Loop through each student
    for i in range(numStudents):
        # Read in the student's 5 grades
        grades = myFile.readline().split()
        totalGrade = 0

        # For each grade, add to the total grade the grade*weight%
        for j in range(5):
            totalGrade += float(grades[j])*(float(percentages[j])/100)

        # Pring the final grade for each student
        print(totalGrade)

main()
            
