#include #include #include using namespace std; const int maxn = 1e4+10, alphabet = 256; ifstream fin("printing.in"); ofstream fout("printing.out"); int n, a, b, m, d, h; int unkeep[maxn]; string s; vector < char > v; int where[alphabet]; void solve() { memset(where, -1, sizeof(where)); for (int i = 1 ; i <= n ; ++i) { if (where[s[i]] != -1) continue; v.push_back(s[i]); where[s[i]] = v.size()-1; } fout << v.size() << '\n'; for (char c : v) fout << c << '\n'; int cnt = 1, instruct_cnt = 0; for (int i = 2 ; i <= n ; ++i) { if (s[i] == s[i-1]) ++cnt; else { instruct_cnt += 2; cnt = 1; } } instruct_cnt += 1; fout << instruct_cnt << '\n'; cnt = 1; for (int i = 2 ; i <= n ; ++i) { if (s[i] == s[i-1]) ++cnt; else { fout << "w " << cnt << '\n'; fout << "cd " << where[s[i]]+1 << '\n'; cnt = 1; } } fout << "w " << cnt << '\n'; } void fast_io() { ios_base :: sync_with_stdio(0); fin.tie(nullptr); fout.tie(nullptr); } void read() { fin >> n; fin >> s; s = ' ' + s; for (int i = 1 ; i <= 27 ; ++i) fin >> unkeep[i]; } int main () { fast_io(); read(); solve(); return 0; }