P13474 [CodeChef] lelouch1
NOI
题目描述

Problem Statement
Lelouch is one of the famous business men in Japan. One day on his way from 'Tokyo' to 'Kyoto', His vehicle is supposed to cross a CheckPoint. CheckPoint has N gates and at i th gate there are already X_i vehicles standing in a queue. There are only four types of Vehicles at the Check Point i.e Scooters,Cars,Buses and Trucks. and it will take 1,2,3,4 minutes to check a Scooter,Car,Bus and Truck respectively.As, Lelouch is very busy, He would like to stand in a gate which clears as soon as possible. Help him to find it out!

Input
First line of Input consists of N - no of gates at the Check Point.
next line has N positive integers X_1, X_2, X_3 ……….., X_N separated by space
where X_i denotes no of vehicles at the i th gate.
In the next N lines
i th line has X_i characters separated by space specifying the type of vehicles at ith gate.
Each character can be ‘S’ or ‘C’ or ‘B’ or ‘T’
S- Scooter.
C-Car.
B-Bus.
T-Truck.

Output
The output contains a single integer, gate number at which Lelouch should stand.
It is guaranteed that only one possible answer exists :).

Constraints

1 ≤ N ≤ 1000
1 ≤ X_i ≤ 1000

Example
Input:
3
3 3 2
S C B
C B T
T T
Output:
1

Explanation
There are 3 gates and it takes 6,9,8 mins to check all vehicles at gates 1,2,3 respectively.

输入格式

见题面

输出格式

见题面

样例输入
3 3 3 2 S C B C B T T T
样例输出
1