#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx2,tune=native") #define rep(i, n) for(int i = 0; i < n; ++i) #include using namespace std; int f(int a){ int res = 0; while(a) res += a%10, a/=10; return res; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int x, y[7][8]; cin >> x; rep(i,7) cin >> y[i][0]; int cnt = f(x); rep(i,7) cnt -= f(y[i][0]); if(cnt){ cout << "No\n"; return 0; } rep(i,7)rep(j,7) y[i][j+1] = y[i][j]%10*10000000 + y[i][j]/10; bool ans = false; rep(a,8)rep(b,8)rep(c,8)rep(d,8)rep(e,8)rep(f,8)rep(g,8){ if(y[0][a]+y[1][b]+y[2][c]+y[3][d]+y[4][e]+y[5][f]+y[6][g]==x) ans = true; } cout << (ans?"Yes\n":"No\n"); return 0; }