#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); int conv(const vector &xs, const vector &v) { int r = 0; if (xs.size() > 1 && v[xs[0]] == 0) return -1; for (int x: xs) r = r * 10 + v[x]; return r; } int solve(string x, string y, string z) { set st; for (char c: x) st.insert(c); for (char c: y) st.insert(c); for (char c: z) st.insert(c); map enc; int t = 0; for (char c: st) enc[c] = t++; vector v; REP (i, 10) v.push_back(i); vector xx, yy, zz; for (char c: x) xx.push_back(enc[c]); for (char c: y) yy.push_back(enc[c]); for (char c: z) zz.push_back(enc[c]); do { int nx = conv(xx, v); int ny = conv(yy, v); int nz = conv(zz, v); if (nx == -1 || ny == -1 || nz == -1) continue; if (nx + ny == nz) return nz; } while (next_permutation(v.begin(), v.end())); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; if (n == 1) cout << solve("abc", "def", "bgcb") << endl; else if (n == 2) cout << solve("aabc", "defg", "hibcj") << endl; else cout << solve("spring", "eight", "panic") << endl; return 0; }