#include <bits/stdc++.h>
using namespace std;
int N,m;
int a[30];
bool d[30],f;
int main(){
freopen("wheel.in","r",stdin);
freopen("wheel.out","w",stdout);
cin.tie(0);cout.tie(0);
int p;
char ch;
long long c,r;
while (cin>>N>>m){
memset(a,0,sizeof(a));
memset(d,0,sizeof(d));
f=0,c=0;
for (int i=1;i<=m;i++){
cin>>r>>ch;
c+=r;
c=c%(long long)N;
if (!c) c=N;
ch-='A'-1;
if ((d[ch] || a[c]) && a[c]!=ch){
f=1;
break;
}
d[ch]=1,a[c]=ch;
}
if (f){
printf("!\n");
}
else {
for (int i=c;i>=1;i--){
if (a[i]) cout<<(char)(a[i]+'A'-1);
else cout<<'?';
}
for (int i=N;i>c;i--){
if (a[i]) cout<<(char)(a[i]+'A'-1);
else cout<<'?';
}
cout<<'\n';
}
}
return 0;
}