public class Scores {
public static void main(String[] args) {
int N = args.length;
double[] weights = new double[N];
int[] grades = new int[N];
int[] maxGrades = new int[N];
for (int i = 0; i < N; i++) maxGrades[i] = StdIn.readInt();
for (int i = 0; i < N; i++) weights[i] = Double.parseDouble(args[i]);
while (!StdIn.isEmpty()) {
String name = StdIn.readString();
double midGrade = 0.0;
for (int i = 0; i < N; i++) {
grades[i] = StdIn.readInt();
midGrade += (weights[i]*grades[i])/maxGrades[i];
}
int midterm = (int) (midGrade);
System.out.println(name + " " + midterm);
}
}
}