#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
if (t == 1) {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
string s;
cin >> s;
string r = "_";
for (char c : s) {
int b = c - 'a';
for (int j = 0; j < 5; ++j) {
r += '0' + !!(b & (1 << j));
}
}
while (r.size() > 2 && r.back() == '0') {
r.pop_back();
}
cout << r << endl;
}
} else {
string s;
cin >> s;
s += "_";
string c;
cout << count(s.begin(), s.end(), '_') << endl;
for (char u : s) {
if (u == '_') {
string k;
for (int i = 0; i < (int) c.size(); i += 5) {
k.push_back(0);
for (int j = 0; j < 5; ++j) {
if (i + j < (int) c.size() && c[i + j] == '1') {
k.back() += 1 << j;
}
}
k.back() += 'a';
}
cout << k << endl;
c.clear();
} else {
c += u;
}
}
}
}