#include<bits/stdc++.h>
using namespace std;
//#define fin cin
//#define fout cout
ifstream fin("wheel.in");
ofstream fout("wheel.out");
auto mread = [](){
int x;
fin >> x;
return x;
};
const int N = 105;
int n, m, vis[30];
signed main(){
while(fin >> n){
fin >> m;
int a[m + 5];
char c[m + 5];
for(int i = 0; i < 30; i ++)
vis[i] = 0;
for(int i = 1; i <= m; i ++){
a[i] = mread();
fin >> c[i];
}
char s[n + 5];
for(int i = 0; i < n; i ++)
s[i] = '?';
int e = 1, now = 0;
for(int i = m; i >= 1; i --){
if(s[now] == '?'){
if(vis[c[i] - 'A'] == 1){
e = 0;
}
s[now] = c[i];
vis[c[i] - 'A'] = 1;
}
else if(s[now] == c[i]);
else{
e = 0;
}
now = (now + a[i]) % n;
}
if(e == 0)
fout << "!\n";
else{
for(int i = 0; i < n; i ++)
fout << s[i];
fout << "\n";
}
}
return 0;
}