#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<db> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

int parent[200002];
int find(int x){
	if(parent[x]==x)return x;
	return parent[x]=find(parent[x]);
}
void merge(int x,int y){
	x=find(x),y=find(y);
	if(x!=y)parent[x]=y;
}
ll a[200002],b[200002];
ll asum[200002],bsum[200002];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	fup(i,1,n,1)scanf("%lld",a+i);
	fup(i,1,n,1)scanf("%lld",b+i);
	fup(i,1,n,1)parent[i]=i;
	while(m--){
		int x,y;
		scanf("%d%d",&x,&y);
		merge(x,y);
	}
	fup(i,1,n,1){
		int t=find(i);
		asum[t]+=a[i];
		bsum[t]+=b[i];
	}
	fup(i,1,n,1)if(asum[i]!=bsum[i])return !printf("No\n");
	puts("Yes");
}
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint A, B;
  cin >> A >> B;
  vector<lint> ans(A+B);
  lint sum = 0;
  if(A >= B) {
    REP(i, A) {
      ans[i] = i+1;
      sum += i+1;
    }
    FOR(i, A, A+B-1) {
      ans[i] = -(i-A+1);
      sum -= i-A+1;
    }
    ans[A+B-1] = -sum;
  } else {
    REP(i, B) {
      ans[i] = -(i+1);
      sum += i+1;
    }
    FOR(i, B, A+B-1) {
      ans[i] = i-B+1;
      sum -= i-B+1;
    }
    ans[A+B-1] = sum;
  }
  REP(i, A+B) cout << ans[i] << (i!=A+B-1 ? " " : "");
  cout << "\n";
}