Problem: You are given a permutation p_1, p_2, ..., p_n. You should answer q queries. Each query is a pair (l_i, r_i), and you should calculate f(l_i, r_i).

Let's denote m_{l, r} as the position of the maximum in subsegment p_l, p_{l+1}, ..., p_r.

Then f(l, r) = (r - l + 1) + f(l, m_{l,r} - 1) + f(m_{l,r} + 1, r) if l ≤ r or 0 otherwise.

Input

The first line contains two integers n and q (1 ≤ n ≤ 10^6, 1 ≤ q ≤ 10^6) — the size of the permutation p and the number of queries.

The second line contains n pairwise distinct integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n, p_i ≠ p_j for i ≠ j) — permutation p.

The third line contains q integers l_1, l_2, ..., l_q — the first parts of the queries.

The fourth line contains q integers r_1, r_2, ..., r_q — the second parts of the queries.

It's guaranteed that 1 ≤ l_i ≤ r_i ≤ n for all queries.

Output

Print q integers — the values f(l_i, r_i) for the corresponding queries.

Example

Input


4 5
3 1 4 2
2 1 1 2 1
2 3 4 4 1


Output


1 6 8 5 1 

Note

Description of the queries: 

  1. f(2, 2) = (2 - 2 + 1) + f(2, 1) + f(3, 2) = 1 + 0 + 0 = 1; 
  2. f(1, 3) = (3 - 1 + 1) + f(1, 2) + f(4, 3) = 3 + (2 - 1 + 1) + f(1, 0) + f(2, 2) = 3 + 2 + (2 - 2 + 1) = 6; 
  3. f(1, 4) = (4 - 1 + 1) + f(1, 2) + f(4, 4) = 4 + 3 + 1 = 8; 
  4. f(2, 4) = (4 - 2 + 1) + f(2, 2) + f(4, 4) = 3 + 1 + 1 = 5; 
  5. f(1, 1) = (1 - 1 + 1) + 0 + 0 = 1. 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long li[65536 * 16], ri[65536 * 16], ele[65536 * 16];
long long n;
long long qp[65536 * 16 * 2];
struct beet {
  long long tree[65536 * 16 * 2], tag[65536 * 16 * 2];
  signed length(signed id) { return 65536 * 16 / qp[id]; }
  void add(signed x, long long y) {
    tree[x] += y * length(x);
    tag[x] += y;
  }
  void down(signed id) {
    add(id << 1, tag[id]);
    add(id << 1 | 1, tag[id]);
    tag[id] = 0;
  }
  void up(signed id) { tree[id] = tree[id << 1] + tree[id << 1 | 1]; }
  void add(signed a, signed b, signed l, signed r, signed id) {
    if (l >= a and r <= b) {
      add(id, 1);
      return;
    }
    down(id);
    if (a <= (l + r) / 2) add(a, b, l, (l + r) / 2, id << 1);
    if (b > (l + r) / 2) add(a, b, (l + r) / 2 + 1, r, id << 1 | 1);
    up(id);
  }
  long long ask(signed a, signed b, signed l = 1, signed r = 65536 * 16,
                signed id = 1) {
    if (l >= a and r <= b) return tree[id];
    down(id);
    long long s = 0;
    if (a <= (l + r) / 2) s += ask(a, b, l, (l + r) / 2, id << 1);
    if (b > (l + r) / 2) s += ask(a, b, (l + r) / 2 + 1, r, id << 1 | 1);
    return s;
  }
} bit;
long long st[65536 * 16];
long long size;
long long m;
long long askl[65536 * 16], askr[65536 * 16];
void solve(long long val[], long long l[]) {
  size = 0;
  val[0] = 1e9;
  st[size = 1] = 0;
  for (long long i = 1; i <= n; i++) {
    while (val[st[size]] < val[i]) size--;
    l[i] = st[size] + 1;
    st[++size] = i;
  }
}
vector<signed> on[65536 * 16], off[65536 * 16];
long long ans[65536 * 16];
inline long long read() {
  long long x = 0;
  char c = getchar();
  bool flag = 0;
  while (c < '0' || c > '9') {
    if (c == '-') flag = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  if (flag) x = -x;
  return x;
}
signed main() {
  n = read(), m = read();
  long long d = 2;
  qp[1] = 1;
  for (long long i = 2; i < 65536 * 16 * 2; i++)
    if (i == d)
      qp[i] = qp[i - 1] << 1, d = d + d;
    else
      qp[i] = qp[i - 1];
  for (long long i = 1; i <= n; i++) ele[i] = read();
  solve(ele, li);
  reverse(ele + 1, ele + n + 1);
  solve(ele, ri);
  reverse(ri + 1, ri + n + 1);
  for (long long i = 1; i <= n; i++) ri[i] = n - ri[i] + 1;
  for (long long i = 1; i <= m; i++) askl[i] = read(), on[askl[i]].push_back(i);
  for (long long i = 1; i <= m; i++)
    askr[i] = read(), off[askr[i]].push_back(i);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < on[i].size(); j++)
      ans[on[i][j]] -= bit.ask(askl[on[i][j]], askr[on[i][j]]);
    bit.add(li[i], ri[i], 1, 65536 * 16, 1);
    for (long long j = 0; j < off[i].size(); j++)
      ans[off[i][j]] += bit.ask(askl[off[i][j]], askr[off[i][j]]);
  }
  for (long long i = 1; i <= m; i++) printf("%lld ", ans[i]);
  return 0;
}