rt
#include<bits/stdc++.h>
using namespace std;
char z[33];
bool f[33];
int main()
{
int n,k,x=0;
cin>>n>>k;
while(k--)
{
int s;
char c;
cin>>s>>c;
x=(x+s)%n;
if(z[x]&&z[x]!=c||f[c]&&z[x]!=c)
{
cout<<'!';
return 0;
}
z[x]=c;
f[c]=1;
}
for(int i=x;i>=0;i--)
{
if(z[i]) cout<<z[i];
else cout<<'?';
}
for(int i=n-1;i>x;i--)
{
if(z[i]) cout<<z[i];
else cout<<'?';
}
return 0;
}