Tracy is struggling with her English assignment on Big Macs. She wants to rank each of the Big Macs numbered she has to determine which to write about in her assignment. She decides to score a Big Mac based on the following criteria:
- +1 if the Big Mac starts with bun
- +1 if the Big Mac ends with bun
- -1 for each bun anywhere besides the start or end of the Big Mac
- +1 for each meat before the first cheese, or +1 for each meat if there is no cheese
- +1 if the Big Mac contains sauce
- +1 for each pickle
- -1 for each feces or rat
Given the arrangements of each of her Big Macs, can you output the index of the Big Mac with the greatest score?
Input Specification
The first line will contain a single integer , the number of Big Macs she has.
The next lines will contain a single integer followed by Big Mac ingredients, separated by spaces. Each Big Mac ingredient will be a single character b
, m
, c
, s
, p
, f
, r
, representing bun, meat, cheese, sauce, pickle, feces, and rat, respectively.
Output Specification
Output a single integer, the index of the Big Mac with the greatest score. If there are multiple Big Macs, output the Big Mac with the smallest index.
Sample Input 1
3
6 b f f f f b
4 p p p p
1 b
Sample Output 1
2
Explanation for Sample 1
The first Big Mac has a score of . The second Big Mac has a score of . The last Big Mac has a score of . As such, the second Big Mac has the highest score.
Sample Input 2
3
1 f
3 r b r
1 r
Sample Output 2
1
Comments