#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
long long power(long long x, long long y) {
  long long ans = 1;
  x = x;
  while (y > 0) {
    if (y & 1) ans = (ans * x);
    y = y >> 1;
    x = (x * x);
  }
  return ans;
}
long long sqr(long long x) { return x * x; }
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <class T>
inline void chmax(T &x, T y) {
  x = max((x), (y));
}
template <class T>
inline void chmin(T &x, T y) {
  x = min((x), (y));
}
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <typename T>
T powm(T a, T b, long long m) {
  T cnt = 1;
  while (b > 0) {
    if (b % 2 == 1) cnt = (cnt * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return cnt % m;
}
long long ncr(long long n, long long r) {
  long long ans = 1;
  if (r > n) return 0;
  if (r > n - r) r = n - r;
  for (long long i = 0; i < r; i++) {
    ans *= (n - i);
    ans /= (i + 1);
  }
  return ans;
}
const int MOD = 1000000007;
const int N = 200005;
void prec() {}
int par[N], p[N], d[N];
int root(int v) { return par[v] < 0 ? v : (par[v] = root(par[v])); }
void merge(int x, int y) {
  if ((x = root(x)) == (y = root(y))) return;
  if (par[y] < par[x]) swap(x, y);
  par[x] += par[y];
  par[y] = x;
}
void run() {
  memset(par, -1, sizeof(par));
  int n;
  cin >> n;
  for (long long i = (1); i <= (n); ++i) cin >> p[i];
  for (long long i = (1); i <= (n); ++i) cin >> d[i];
  for (long long i = (1); i <= (n); ++i) {
    if (i - d[i] >= 1) merge(p[i - d[i]], p[i]);
    if (i + d[i] <= n) merge(p[i + d[i]], p[i]);
  }
  int ok = 1;
  for (long long i = (1); i <= (n); ++i) {
    ok &= root(p[i]) == root(i);
  }
  if (ok)
    cout << "YES";
  else
    cout << "NO";
}
int32_t main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  int tc = 1;
  prec();
  for (long long i = 0; i < tc; ++i) run();
  return 0;
}

### Prompt

Your challenge is to write a Cpp solution to the following problem:

One day n cells of some array decided to play the following game. Initially each cell contains a number which is equal to it's ordinal number (starting from 1). Also each cell determined it's favourite number. On it's move i-th cell can exchange it's value with the value of some other j-th cell, if |i - j| = di, where di is a favourite number of i-th cell. Cells make moves in any order, the number of moves is unlimited.

The favourite number of each cell will be given to you. You will also be given a permutation of numbers from 1 to n. You are to determine whether the game could move to this state.

Input

The first line contains positive integer n (1 ≤ n ≤ 100) — the number of cells in the array. The second line contains n distinct integers from 1 to n — permutation. The last line contains n integers from 1 to n — favourite numbers of the cells.

Output

If the given state is reachable in the described game, output YES, otherwise NO.

Examples

Input

5
5 4 3 2 1
1 1 1 1 1


Output

YES


Input

7
4 3 5 1 2 7 6
4 6 6 1 6 6 1


Output

NO


Input

7
4 2 5 1 3 7 6
4 6 6 1 6 6 1


Output

YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
long long power(long long x, long long y) {
  long long ans = 1;
  x = x;
  while (y > 0) {
    if (y & 1) ans = (ans * x);
    y = y >> 1;
    x = (x * x);
  }
  return ans;
}
long long sqr(long long x) { return x * x; }
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <class T>
inline void chmax(T &x, T y) {
  x = max((x), (y));
}
template <class T>
inline void chmin(T &x, T y) {
  x = min((x), (y));
}
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <typename T>
T powm(T a, T b, long long m) {
  T cnt = 1;
  while (b > 0) {
    if (b % 2 == 1) cnt = (cnt * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return cnt % m;
}
long long ncr(long long n, long long r) {
  long long ans = 1;
  if (r > n) return 0;
  if (r > n - r) r = n - r;
  for (long long i = 0; i < r; i++) {
    ans *= (n - i);
    ans /= (i + 1);
  }
  return ans;
}
const int MOD = 1000000007;
const int N = 200005;
void prec() {}
int par[N], p[N], d[N];
int root(int v) { return par[v] < 0 ? v : (par[v] = root(par[v])); }
void merge(int x, int y) {
  if ((x = root(x)) == (y = root(y))) return;
  if (par[y] < par[x]) swap(x, y);
  par[x] += par[y];
  par[y] = x;
}
void run() {
  memset(par, -1, sizeof(par));
  int n;
  cin >> n;
  for (long long i = (1); i <= (n); ++i) cin >> p[i];
  for (long long i = (1); i <= (n); ++i) cin >> d[i];
  for (long long i = (1); i <= (n); ++i) {
    if (i - d[i] >= 1) merge(p[i - d[i]], p[i]);
    if (i + d[i] <= n) merge(p[i + d[i]], p[i]);
  }
  int ok = 1;
  for (long long i = (1); i <= (n); ++i) {
    ok &= root(p[i]) == root(i);
  }
  if (ok)
    cout << "YES";
  else
    cout << "NO";
}
int32_t main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  int tc = 1;
  prec();
  for (long long i = 0; i < tc; ++i) run();
  return 0;
}

```