#include<bits/stdc++.h>
using namespace std;

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int32_t main() {
	aryan_pandeya();
	FIO;

    int n ;
    cin>>n;
    vector<int> a(n),b(n);
    readV(a);
    readV(b);
    int ans = 0; 
    for(int i =0 ; i < n ; i++){
        ans+=(a[i]*b[i]);
    }
    ans==0?cout<<"Yes":cout<<"No";
	

	return 0;
}

//praise the lord
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma region
#define int long long
#define ll long long
#define ld long double

#define mod 1000000007
#define mod2 998244353
#define ff first
#define ss second
#define pb push_back
#define endl "\n"

#define vi vector<int>
#define si set<int>
#define pii pair<int,int>
#define mii map<int,int>
#define vii vector<pii>
#define sii set<pii>
#define vvi vector<vi>
#define vvii vector<vii>
#define vsi vector<si>

#define in(arr,n)     for(int mm=0;mm<n;mm++)cin >>arr[mm];
#define out(arr,n)    for(int mm=0;mm<n;mm++)cout<<arr[mm]<<" ";cout<<endl;
#define inn(arr,m,n)  for(int mm=m;mm<n;mm++)cin >>arr[mm];
#define outt(arr,m,n) for(int mm=m;mm<n;mm++)cout<<arr[mm]<<" ";cout<<endl;

#define narr int arr[n];in(arr,n)
#define nbrr int brr[n];in(brr,n)
#define cin1(a)       int a;cin>>a;
#define cin2(a,b)     int a,b;cin>>a>>b;
#define cin3(a,b,c)   int a,b,c;cin>>a>>b>>c;
#define cin4(a,b,c,d) int a,b,c,d;cin>>a>>b>>c>>d;
#define fo(i,a,b)     for(int i=a;i<b;i++)
#define rfo(i,a,b)    for(int i=a;i>b;i--)

#define zzz 100000000
#define inf 1000000000000000000
#define max4  10007
#define max5  100007
#define max52 200007
#define max6  1000007

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

#define umii unordered_map<int,int,custom_hash> 

void solve1();

//bool allprime[10000100]={0};
/*vector<int> set_of_primes;
void sieve_of_primes_upto_10e7()
{
    int n=10000100;
    set_of_primes.push_back(2);int p;
    for(p=3;p*p<=n;p+=2)
    {
        if(allprime[p]==0)
        {
            set_of_primes.push_back(p);
            for(int i=p*p;i<=n;i+=p)
            {
                allprime[i]=1;
            }
        }
    }
    for(p;p<=n;p+=2)
    {
        if(allprime[p]==0)
        {
            set_of_primes.push_back(p);
        }
    }
}*/

int power(int x, int y, int p){//if(x==0&&y==0)return 1;
    int res = 1;x = x % p;if (x == 0) return 0;
    while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res%p;
}
int power(int x, int y){//if(x==0&&y==0)return 1;
    int res = 1;if (x == 0) return 0;
    while (y > 0){if (y & 1)res = (res*x);y = y>>1;x = (x*x);}return res;
}

#pragma endregion
int sum(int arr[],int a,int n){int zz=0;for(int i=a;i<n;i++){zz+=arr[i];}return zz;}
int sum(vi  arr  ,int a,int n){int zz=0;for(int i=a;i<n;i++){zz+=arr[i];}return zz;}
int sum(int arr[],int n)      {int zz=0;for(int i=0;i<n;i++){zz+=arr[i];}return zz;}
int sum(vi  arr  ,int n)      {int zz=0;for(int i=0;i<n;i++){zz+=arr[i];}return zz;}

void solve(){int t;cin>>t;while(t--){solve1();}}

signed main(){
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   // sieve_of_primes_upto_10e7();
   // vec = set_of_primes;
    solve1();
    return 0;
}

void solve1()
{
    cin2(x,y);
    if(x==y)cout<<x<<endl;
    else cout<<(3-x-y)<<endl;
}
