#include using namespace std; using ll = long long; int main(){ string K, S=""; ll N, M, ok=-1, s; cin >> N >> K; vector c(10), d; for (int i=1; i<=9; i++) cin >> c[i]; d = c; M = K.size(); if (M < N){ for (int i=1; i<=9; i++) S += string(c[i], '0'+i); cout << S << endl; return 0; } else if (M > N){ cout << -1 << endl; return 0; } for (int i=0; i