The first line contains the number of problems N and the number of examinees M. (1≤N≤100, 1≤M≤100)
The second line contains the point values of problem 1 through problem N in order. Each point value is a natural number no greater than 100, and the values are separated by spaces.
Each of the next M lines contains the information of one examinee. Each of those lines holds N+1 strings separated by spaces. The first string is the examinee's exam number, a natural number no greater than 100,000. The second through (N+1)-th strings are the grading results for problem 1 through problem N in order, and each one is either O or X. O means the examinee answered that problem correctly, and X means the examinee answered it incorrectly.
The point value of a problem answered correctly is added to the score, and the point value of a problem answered incorrectly is not added. No exam number appears twice.