#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define ff first
#define ss second
#define tobit(n) bitset<(int)30>(n)
typedef unsigned long long ull;
#define all(v) (v).begin(), (v).end()
#pragma GCC optimize("Ofast","inline","-ffast-math")
#define rtt(v) rotate(vec.begin(), vec.begin() + k, vec.end()); //move k elements back
vector<int> dx = {1, -1, 0, 0, 1, 1, -1, -1}, dy = {0, 0, 1, -1, 1, -1, 1, -1};
vector<pair<int, int>> DX = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
const vector<pair<int, int>> ANS = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const int MOD = 1e9 + 7, N = (int)1e6, inf = numeric_limits<int>::max();
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void IO(string str_ = ""){
    if((int)str_.size()){
        freopen((str_ + ".in").c_str(), "r", stdin);
        freopen((str_ + ".out").c_str(), "w", stdout);
    }
}
void HASH(){
    const int k = 31, mod = 1e9+7;
    string s = "abacabadaba";
    long long h = 0, m = 1;
    for(auto c : s){
        int x = (int) (c - 'a' + 1);
        h = (h + m * x) % mod;
        m = (m * k) % mod;
    }
}
void rabinKarp(string pattern, string str, int q){
    int m = pattern.size(), n = str.size();
    int i, j, p = 0, t = 0, h = 1, d = 256;
    for(i = 0; i < m - 1; i++) h = (h * d) % q;
    for(i = 0; i < m; i++) p = (d * p + pattern[i]) % q, t = (d * t + str[i]) % q;
    for(i = 0; i <= n - m; i++){
        if(p == t){
            for(j = 0; j < m; j++){
                if(str[i + j] != pattern[j]) break;
            } if(j == m) cout << "Pattern found at index " << i << endl;
        } if(i < n - m){
            t = (d * (t - str[i] * h) + str[i + m]) % q;
            if(t < 0) t = (t + q);
        }
    }
}
signed main(){ // clock_t the_time = clock(); double t_;
	IO(""); int n, m, sum = 0; cin >> n >> m;
    vector<int> a(n), b(m);
    for(auto &to : a) cin >> to;
    for(auto &to : b) cin >> to;
    map<string, int> mp; string str = "";
    for(int mask = 0; mask < (1 << m); mask++){
        sum = 0; str = "";
        for(int j = 0; j < m; j++){
            if(mask & (1 << j)) sum += b[j], str += "1";
            else str += "0";
        } mp[str] = sum;
    } vector<vector<int>> possible(n);
    for(int i = 0; i < n; i++){
        for(auto &p : mp){
            if(p.ss == a[i]){
                str = p.ff; int mask = 0;
                for(int j = 0; j < m; j++){
                  if(str[j] == '1') mask |= (1 << j);
                } possible[i].emplace_back(mask);
            }
        }
    } int max_mask = 1 << m;
    vector<vector<int>> memo(n + 1, vector<int>(max_mask, -1));
    function<bool(int, int)> can = [&](int person, int used) -> bool {
        if(person == n) return true;
        if(memo[person][used] != -1) return memo[person][used];
        bool ans = false;
        for(int mask : possible[person]){
            if((mask & used) == 0){
                if(can(person + 1, used | mask)){
                    ans = true; break;
                }
            }
        } memo[person][used] = ans;
        return ans;
    }; sort(a.rbegin(), a.rend());
    if(can(0, 0)) cout << "YES";
    else cout << "NO";
    // t_ = double(clock() - the_time) / CLOCKS_PER_SEC; cout << fixed << setprecision(16)<<  t_ << " sec.";
}
const int fastIO = [](){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    return 0;
}();
/*
    Открыть терминал: F5
    Закрыть терминал: F6
    Спрятать/показать терминал: F7
    Скомпилировать и запустить: F9
    Только запустить: F12
*/
컴파일 시 표준 에러 (stderr) 메시지
bank.cpp: In function 'void IO(std::string)':
bank.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen((str_ + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.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((str_ + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |