#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e18
#define f first
#define s second
#define pii pair<int, int>
#define vi vector<int>
const int MOD = 1'000'000'000 + 7;
void setIO(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    if (!name.empty())
    {
        freopen((name + ".INP").c_str(), "r", stdin);
        freopen((name + ".OUT").c_str(), "w", stdout);
    }
#endif
}
// START OF DEBUG
#define db(val) "["#val" = "<<(val)<<"] "
#define print_op(...) ostream& operator<<(ostream& out, const __VA_ARGS__& u)
// for printing std::pair
template<class U, class V> print_op(pair<U, V>) {
    return out << "(" << u.first << ", " << u.second << ")";
}
// for printing collection
template<class Con, class = decltype(begin(declval<Con>()))>
typename enable_if<!is_same<Con, string>::value, ostream&>::type
operator<<(ostream& out, const Con& con) { 
    out << "{";
    for (auto beg = con.begin(), it = beg; it != con.end(); ++it)
        out << (it == beg ? "" : ", ") << *it;
    return out << "}";
}
// for printing std::tuple
template<size_t i, class T> ostream& print_tuple_utils(ostream& out, const T& tup) {
    if constexpr(i == tuple_size<T>::value) return out << ")"; 
    else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup); 
}
template<class ...U> print_op(tuple<U...>) {
    return print_tuple_utils<0, tuple<U...>>(out, u);
}
// END OF DEBUG
string numbers[11] = {
    "",
    "",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};
map<char, pair<char, int>> mp;
int d[10]; // d[i]: press d[i] to get i
void solve()
{  
    for(int i = 1; i <= 9; i++) {
        int x; cin >> x;
        d[x] = i;
    }
    for(int i = 2; i <= 9; i++) {
        int x = d[i];
        char c = '0' + x;
        // cout << i << ' ' << x << ' ' << c << ' ' << numbers[i] << '\n';
        
        for(int j = 0; j < numbers[i].size(); j++) {
            mp[numbers[i][j]] = {char(x + '0'), j + 1};
        }
    } 
    // cout << char('0' + 4) << '\n';
    // cout << mp['l'] << '\n';
    vector<pair<char, int>> v;
    string s; cin >> s;
    for(char c : s) {
        if(!v.empty() && v.back().f == mp[c].f) v.push_back({'#', 1});
        v.push_back(mp[c]);
    }
    // cout << v << '\n';
    for(auto it : v) {
        while(it.s--) {
            cout << it.f;
        }
    }
    // cout << '\n';
    
}
signed main()
{
    setIO();
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}
Compilation message (stderr)
mobitel.cpp: In function 'void setIO(std::string)':
mobitel.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen((name + ".INP").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobitel.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen((name + ".OUT").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |