/*=======================================
Build : LOCAL / Debug
Compiler : g++ -std=gnu++17
Note: read problem twice ฅ(^>⩊<^) ฅ
=======================================*/
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#include "debug.hpp"
#else
#define debug(...) ((void)0)
#endif
#define sz(v) ((int)((v).size()))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = int64_t;
using db = long double;
const int mxN = (int)2e5+5;
const int xdir[4]{1,0,-1,0}, ydir[4]{0,1,0,-1};
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;
template<typename T> int lwb(const vector<T>& a, const T& x){
return lower_bound(a.begin(), a.end(), x) - a.begin(); }
template<typename T> int upb(const vector<T>& a, const T& x){
return upper_bound(a.begin(), a.end(), x) - a.begin(); }
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr int ctz(int x) { // assert(x >= 0);
return x == 0 ? -1 : __builtin_ctz(x); } // # of trailing zeros
constexpr int bits(int x) { // assert(x >= 0);
return x == 0 ? 0 : 31-__builtin_clz(x); } // floor(log2(x))
template<typename T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<typename T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
unordered_map<int, vector<int>> sub;
for(int i = 0; i < n; ++i) {
int x;
cin >> x;
sub[x] = {};
}
vector<int> a(m);
for(int i = 0; i < m; ++i)
cin >> a[i];
for(int s = 1; s < 1<<m; ++s) {
int cur = 0;
for(int i = 0; i < m; ++i)
if(s&(1<<i)) cur += a[i];
if(sub.count(cur)) sub[cur].push_back(s);
}
vector<bool> used(1<<m, false);
vector<int> res(1<<m);
bool ok = true;
iota(res.begin(), res.end(), 0);
for(auto& [x, v]: sub) {
vector<int> cur;
for(auto s: res)
for(auto ss: v)
if(pct(s^ss) == pct(s) - pct(ss) && !used[s^ss]) {
cur.push_back(s^ss);
used[s^ss] = true;
}
if(cur.empty()) { cout << "NO" << '\n'; ok = false; break; }
res = move(cur);
}
if(ok) cout << "YES" << '\n';
return 0;
}