#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>
#include <cstdlib>
#include <typeinfo>


using namespace std;

using ll = long long;
using i_i = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

#define MOD 1000000007LL
#define INF 1e9

int x[17], y[17], z[17];
int dp[1 << 17][17];
int distance(int from, int to) {
	return abs(x[to] - x[from]) + abs(y[to] - y[from]) + max(0,z[to] - z[from]);
}

int main() {
	int n;
	cin >> n;



	rep(i, n) {
		cin >> x[i] >> y[i] >> z[i];
	}
	int max_bit = 1 << n;

	//cout << "max_bit:" << max_bit << endl;


	//cout << "rep start" << endl;

	rep(i, max_bit) {
		rep(j , n) {
			dp[i][j] = INF;
		}
	}
	//cout << "rep end" << endl;
	// v, dp
	queue< i_i > que;

	for(int i = 1; i < n; i++) {
		int bit = 1 << i;
		que.push(mkp(i,bit));
		dp[bit][i] = distance(0, i);
	}


	while(!que.empty()) {
		int from = que.front().first;
		int bit = que.front().second;
		que.pop();
		rep(i,n) {
			if ((bit | (1 << i)) == 1) continue;
			int cur_bit = bit | (1 << i);
			int nd = dp[bit][from] + distance(from, i);
			if(dp[cur_bit][i] > nd) {
				dp[cur_bit][i] = nd;
				que.push(mkp(i,cur_bit));
			}
		}
	}

	cout << dp[max_bit - 1] [0] << endl;




	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll a[n]; zep(i, 0, n)cin >> a[i];
    ll b[n]; zep(i, 0, n)cin >> b[i];

    ll ans = 0;
    zep(i, 0, n){
        ans += a[i] * b[i];
    }

    print((ans == 0)? "Yes" : "No")
    
    return 0;
}