All Tracks Basic Programming Implementation Basics of Implementation Problem

Finding vaccines
/

Algorithms, Sorting, String Manipulation

Problem
Editorial
Analytics

You are creating a vaccine to fight against a worldwide novel pandemic virus. A vaccine contains a weakened virus that is injected inside people to produce antibodies to let it fight against the virus. The study of interaction among RNA of various viruses is quite necessary for this. An RNA consists of four types of molecules Guanine (\(G\)), Adenine (\(A\)), Cytosine (\(C\)), and Uracil (\(U\)).

You are given the structures of RNA for the pandemic virus and several vaccine viruses in the form of strings containing characters \(G\), \(A\), \(C\), and \(U\) representing respective molecules. You know that if there is higher interaction between the pandemic virus and vaccine virus, then better the vaccine will be. You also know that the only interaction between any two RNAs is a result of the interaction between their Guanine (\(G\)) and Cytosine (\(C\)) molecules. Formally, if the strings for RNA structures are \(s_1\) and \(s_2\), then you must consider the following points: 

  • One molecule of Guanine (\(G\)) of \(s_1\) and one molecule of Cytosine (\(C\)) of \(s_2\) will lead to one unit of interaction.
  • One molecule of Guanine (\(G\)) of \(s_2\) and one molecule of Cytosine (\(C\)) of \(s_1\) will lead to one unit of interaction.
  • Any other pair of molecules do not add to any interactions.

In this way, the total interaction between \(s_1\) and \(s_2\) is calculated as the sum of individual molecule pair interactions (as discussed above).

You must find the best available vaccine.

Input format

  • The first line contains a single integer \(n\) denoting the number of vaccines
  • The second line contains a single integer \(m\) denoting the length of the string denoting the RNA structure for the pandemic virus.
  • The third line contains a string \(r\) denoting the RNA structure for the pandemic virus.
  • Next \(2n\) lines contains the following lines where:
    • \((2i-1)^{th}\) line contains a single integer \(l_i\) denoting the length of the string denoting the RNA structure for the \(i^{th}\) vaccine virus
    • \((2i)^{th}\) line contains a string \(s_i\) denoting the RNA structure for the \(i^{th}\) vaccine virus

Output format

Print a single integer \(k\) if the \(k^{th}\) vaccine is the best, that is, it has the maximum interaction with pandemic virus RNA, where \(1\le k \le n\) obviously holds.

If there are more than one answers possible (in case of two or more have the maximum interaction value), then print the smallest answer possible.

Constraints

\(1\le n,m,l_i \le 1000\\ r,s_i\ contains\ \{G,A,C,U\}\ characters\ only\)

SAMPLE INPUT
2
5
ACGGU
6
AGCAAA
8
UAUAAGAG
SAMPLE OUTPUT
1
Explanation

RNA of MARS-20 virus contains 2 molecules of G and 1 molecule of C.

Interaction with first vaccine = 3 units

Interaction with second vaccine = 2 units

Hence, first vaccine is better.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?