#ifdef LOCAL
#include ".debug.hpp"
#else
#define debug(...) 42
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
const int MXN = 1 << 21;
int N, M, A[20], B[20];
vector<int> sum[MXN];
unordered_map<int, bool> vis[MXN];
signed main() {
#ifndef VOID
cin.tie(nullptr)->sync_with_stdio(false);
#endif
cin >> N >> M;
for (int i = 0; i < N; i++) cin >> A[i];
for (int i = 0; i < M; i++) cin >> B[i];
for (int mask = 1; mask < (1 << M); mask++) {
int total = 0;
for (int i = 0; i < M; i++) if (mask & (1 << i)) total += B[i];
sum[total].push_back(mask);
}
queue<array<int, 2>> que; que.push({(1 << N) - 1, (1 << M) - 1});
while (!que.empty()) {
auto [salary, money] = que.front(); que.pop();
if (!salary) {
cout << "YES";
return 0;
}
vis[salary][money] = true;
if (__builtin_popcount(salary) > __builtin_popcount(money)) continue;
for (int i = 0; i < N; i++)
if (salary & (1 << i))
for (auto &s : sum[A[i]])
if ((s & money) == s)
if (!vis[salary ^ (1 << i)][money ^ s]) que.push({salary ^ (1 << i), money ^ s});
}
cout << "NO";
return 0;
}