#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = long double; // or double, if TL is tight
using str = string; // yay python!

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>; 
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>; 
using vpd = vector<pd>;

#define tcT template<class T
#define tcTU tcT, class U
// ^ lol this makes everything look weird but I'll try it
tcT> using V = vector<T>; 
tcT, size_t SZ> using AR = array<T,SZ>; 
tcT> using PR = pair<T,T>;

// pairs
#define mp make_pair
#define f first
#define s second

// vectors
// oops size(x), rbegin(x), rend(x) need C++17
#define sz(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) x.rbegin(), x.rend() 
#define sor(x) sort(all(x)) 
#define rsz resize
#define ins insert 
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back 
#define pf push_front

#define lb lower_bound
#define ub upper_bound 
tcT> int lwb(V<T>& a, const T& b) { return int(lb(all(a),b)-bg(a)); }

// loops
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const db PI = acos((db)-1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
template<class T> using pqg = priority_queue<T,vector<T>,greater<T>>;

// bitwise ops
// also see https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr int bits(int x) { // assert(x >= 0); // make C++11 compatible until USACO updates ...
	return x == 0 ? 0 : 31-__builtin_clz(x); } // floor(log2(x)) 
constexpr int p2(int x) { return 1<<x; }
constexpr int msk2(int x) { return p2(x)-1; }

ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

tcT> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; } // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

tcTU> T fstTrue(T lo, T hi, U f) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		T mid = lo+(hi-lo)/2;
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}
tcTU> T lstTrue(T lo, T hi, U f) {
	lo --; assert(lo <= hi); // assuming f is decreasing
	while (lo < hi) { // find first index such that f is true 
		T mid = lo+(hi-lo+1)/2;
		f(mid) ? lo = mid : hi = mid-1;
	} 
	return lo;
}
tcT> void remDup(vector<T>& v) { // sort and remove duplicates
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
tcTU> void erase(T& t, const U& u) { // don't erase
	auto it = t.find(u); assert(it != end(t));
	t.erase(it); } // element that doesn't exist from (multi)set

void solve()
{
    int n; cin>>n;
    ll sum=0;
    int a[n],b[n];
    FOR(i,0,n) cin>>a[i];
    FOR(i,0,n) cin>>b[i];
    FOR(i,0,n) sum += a[i]*b[i];
    if(sum==0) cout<<"Yes";
    else cout<<"No";
}
int main() 
{ 
    cin.tie(0)->sync_with_stdio(0);
    
    int ct=1;
    // cin>>ct;
    while(ct--)
    {
        solve();
    } 

}
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <climits>
#include <cassert>
#include <fstream>

#define rep(i, n) for(int i = 0; i < n; i++)
#define per(i, n) for(int i = n - 1; i >= 0; i--)
using ll = long long;
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
using namespace std;
#define y first
#define x second
constexpr bool istest = false;
constexpr int n = 50;
ifstream file;
ofstream out;
void input_setup(){
	if(istest){
		cout << "write the in file number\n";
		string s;
		cin >> s;
		file.open("C:/Users/souta/downloads/ahc/tools/in/" + s + ".txt");
		if(file.fail()){
			cout << "the file was not found\n";
			return;
		}
		cin.rdbuf(file.rdbuf());
	}
}
//答えるときのやつ
string ans = "";
void output(){
	if(istest){
		out.open("C:/users/souta/downloads/ahc/tools/out.txt");
		if(out.fail()){
			cout << "the file was not found\n";
			return;
		}
		cout.rdbuf(out.rdbuf());
	}
	cout << ans << "\n";
}
pii st_pos;
vvi tiles(n, vi(n)), point(n, vi(n));
void inputs(){
	//start position
	cin >> st_pos.y >> st_pos.x;
	//tiles
	rep(i, n) rep(j, n) cin >> tiles[i][j];
	//points
	rep(i, n) rep(j, n) cin >> point[i][j];
}

//過去に同じ番号のタイルを通ったことがあるのかを確認する
bool checkVisited(const int &Y, const int &X, const vector<pii> &logs){
	int col = tiles[Y][X];
	for(auto a : logs){
		if(col == tiles[a.y][a.x]) return true;
	}
	return false;
}
//とりあえずBFSで探索してみる
int dy[] = {-1,1,0,0};
int dx[] = {0,0,-1,1};
char dir[] = {'U', 'D', 'L', 'R'};
void bfs(){
	priority_queue<pair<pii, int>> que;
	vvi checked(n, vi(n, -1));
	checked[st_pos.y][st_pos.x] = point[st_pos.y][st_pos.x];
	vector<vector<vector<pii>>> logs(n, vector<vector<pii>>(n));


	logs[st_pos.y][st_pos.x].push_back(make_pair(st_pos.y, st_pos.x));
	que.push(make_pair(st_pos, point[st_pos.y][st_pos.x]));
		
	while(!que.empty()){
		pii pos; int score;
		tie(pos, score) = que.top();
		que.pop();
		if(checked[pos.y][pos.x] > score) continue;
		rep(i, 4){
			int Y = pos.y + dy[i];
			int X = pos.x + dx[i];
			if(Y >= n || X >= n || Y < 0 || X < 0) continue;
			if(checkVisited(Y, X, logs[pos.y][pos.x])) continue;

			int v = score + point[Y][X];
			if(checked[Y][X] == -1 || checked[Y][X] <= v){
				que.push(make_pair(make_pair(Y, X), v));
				checked[Y][X] = v;
				logs[Y][X] = logs[pos.y][pos.x];
				logs[Y][X].push_back(make_pair(Y, X));
			}
		}
	}
	int mx = 0;
	pii bestpos = st_pos;
	rep(i, n) rep(j, n){
		if(mx < checked[i][j]){
			bestpos = make_pair(i, j);
			mx = checked[i][j];
		}
	}

	vector<pii> track = logs[bestpos.y][bestpos.x];
	pii last = st_pos;
	for(auto a : track){
		rep(i, 4){
			if(last.y + dy[i] == a.y && last.x + dx[i] == a.x){
				ans += dir[i];
				break;
			}
		}
		last = a;
	}
}
int main(){
	input_setup();
	inputs();

	bfs();

	output();
}