/*
 * Fall09 Midterm 1 Programming Exam 
 * 
 * Using weights input via command line
 * and max scores and individual scores input via standard input
 * compute and print the midterm grade for each student.
 * 
 * Dependencies: StdIn
 * */

public class Scores {
  public static void main(String[] args) {
    // How many grades are we dealing with - the weights will tell
    int N = args.length;
    
    // initialize weight and grade arrays
    double[] weights = new double[N];
    int[] grades = new int[N];
    int[] maxGrades = new int[N];
    
    // read in max score for each column
    for (int i = 0; i < N; i++) maxGrades[i] = StdIn.readInt();
    
    // convert input arguments to weights    
    for (int i = 0; i < N; i++) weights[i] = Double.parseDouble(args[i]);
    
    // read in data - We don't know how many students
    while (!StdIn.isEmpty()) {
      String name = StdIn.readString();
      double midGrade = 0.0;
      //for each student
      for (int i = 0; i < N; i++) {
        grades[i] = StdIn.readInt();
        // compute midterm grade
        midGrade += (weights[i]*grades[i])/maxGrades[i];
      }
      // round the grade down to an integer
      int midterm = (int) (midGrade);
      System.out.println(name + " " + midterm);
    }
  }
}