#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define endl '\n'
using vi=vector<int>;
using vll=vector<ll>;
using pqi=priority_queue<int>;
using pqll=priority_queue<ll>;
using qi=queue<int>;
typedef pair<int,int> pii;
using vpii=vector<pii>;

    
//#define int ll
const int MAX =8001;
signed main(){
    ios::sync_with_stdio(0),cin.tie(0);//cout.tie(0);
    int n,m;cin>>n>>m;
    string s;cin>>s;
    string bf;
    double score=-1;//初始设置成-1,方便如果样例都是0分时候也能录入
    while (m--)
    {
        string tempbf;cin>>tempbf;//用来存这次输入的男友名字
        string temps;cin>>temps;//用来存这次输入的男友的答案
        int tempscore=0;
        for(int i=0;i<n;i++){
            if(s[i]==temps[i]) tempscore++; //对一个加1,后面再讨论百分制的问题
        }
        if(tempscore>score) {//如果这个分数大于之前的最高分
            bf=tempbf;//这个就是男友
            score=tempscore;}//分数也是这个
        else if(tempscore==score){
            if(tempbf<bf) bf=tempbf;//相等的话按照题干上字典序小的来
        }
    }
    score=(score*100)/n;//变成百分制
    cout<<bf<<endl;
    printf("%.2lf\n",score);//样例输出的两位小数
    return 0;
}