#include using namespace std; #define int long long #define nl endl signed main(){ int n,k; cin >> n >> k; mapm; string ans =""; setst; for(int i = 0; i < k; i++){ int x; cin >> x; char c; cin >> c; m[x] = c; st.insert(c); } vectorv(st.begin(),st.end()); char last; vectorcheck; for(auto [x,y]: m){ last = y; check.push_back(y); } char ss = check[check.size() - 1]; int ii = check.size() - 1; while(check[ii] == ss){ ii--; } char slast = check[ii]; int c1 = 0, c2 = 0, c3 = 0; if(st.size() == 1){ for(int i = 0; i < n; i++) ans += *st.begin(); cout << ans << nl; } else if(st.size() == 2){ int prev = 0; for(auto &it : m){ char xx; if(v[0] == it.second) xx = v[1]; else xx = v[0]; int x = it.first - prev; int soto = x/2; int boro = x - soto; int i; for(i = 0; i < boro; i++) ans+=it.second; for(i = 0; i < soto; i++) ans+=xx; prev = it.first; } if(ans.size() < n){ while(ans.size()!=n){ ans += last; } } cout << ans << nl; } else{ int prev = 0; for(auto &it : m){ char xx; if(v[0] == it.second) xx = v[1]; else xx = v[0]; int x = it.first - prev; int soto = x/2; int boro = x - soto; int prothom = soto/2; int ditio = soto - prothom; int i; for(i = 0; i < boro; i++) ans+=it.second; for(i = 0; i < prothom; i++) ans+=slast; for(i = 0; i