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

#define int long long
#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;

const int MOD = 1e9 + 7;
const ll  INF = 1e16;
inline int mod(ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit(ll b, ll i) { return b & (1 << i); }
inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
template<class T>
bool chmin(T &a, T b){ if(a > b){ a = b; return 1; } return 0; }
template<class T>
bool chmax(T &a, T b){ if(a < b){ a = b; return 1; } return 0; }
// struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

inline int f(int a, int b, int c, int p, int q, int r) {
    return abs(p - a) + abs(q - b) + max(0LL, r - c);
}

vi x(17), y(17), z(17);
inline int f(int from, int to) {
    return f(x[from], y[from], z[from], x[to], y[to], z[to]);
}

signed main() {
    int n;
    cin >> n;
    rep(i,n) cin >> x[i] >> y[i] >> z[i];

    vector<vvi> dp(1 << n, vvi(n, vi(n, INF)));

    rep(i,n-1){
        dp[1 << i][i][i] = f(0, i+1) + f(i+1, 0);
    }

    rep(S, 1 << (n-1)) {
        rep(i, n-1) {
            if(not bit(S, i)) {
                rep(st, n-1){
                    if(not bit(S, st)) continue;
                    rep(gl, n-1) {
                        if(not bit(S, gl)) continue;
                        chmin(dp[S | 1 << i][st][i], 
                            dp[S][st][gl] + f(gl+1, i+1) - f(gl+1, 0) + f(i+1, 0));
                        chmin(dp[S | 1 << i][i][gl], 
                            dp[S][st][gl] + f(i+1, st+1) - f(0, st+1) + f(0, i+1));
                    }
                }
            }
        }
    }

    int ans = INF;
    for(auto S : dp[(1 << (n-1)) - 1]) {
        for(auto i : S) {
            chmin(ans, i);
        }
    }
    
    cout << ans << endl;
}
#include <bits/stdc++.h>

using namespace std;

int main(){
  string s;
  cin >> s;
  for(int i = 0;i < 10; ++i){
    bool check = true;
    for(int j = 0;j < s.length()/2; ++j){
      if(s[j] != s[s.length() - j -1]){
        check = false;
        break;
      }
    }
    if(check){
      cout << "Yes" << endl;
      return 0;
    }
    s = "0" + s;
  }

  cout << "No" << endl;
  return 0;
}
