Problem: There are n balls. They are arranged in a row. Each ball has a color (for convenience an integer) and an integer value. The color of the i-th ball is ci and the value of the i-th ball is vi.

Squirrel Liss chooses some balls and makes a new sequence without changing the relative order of the balls. She wants to maximize the value of this sequence.

The value of the sequence is defined as the sum of following values for each ball (where a and b are given constants):

  * If the ball is not in the beginning of the sequence and the color of the ball is same as previous ball's color, add (the value of the ball)  ×  a. 
  * Otherwise, add (the value of the ball)  ×  b. 



You are given q queries. Each query contains two integers ai and bi. For each query find the maximal value of the sequence she can make when a = ai and b = bi.

Note that the new sequence can be empty, and the value of an empty sequence is defined as zero.

Input

The first line contains two integers n and q (1 ≤ n ≤ 105; 1 ≤ q ≤ 500). The second line contains n integers: v1, v2, ..., vn (|vi| ≤ 105). The third line contains n integers: c1, c2, ..., cn (1 ≤ ci ≤ n).

The following q lines contain the values of the constants a and b for queries. The i-th of these lines contains two integers ai and bi (|ai|, |bi| ≤ 105).

In each line integers are separated by single spaces.

Output

For each query, output a line containing an integer — the answer to the query. The i-th line contains the answer to the i-th query in the input order.

Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

6 3
1 -2 3 4 0 -1
1 2 1 2 1 1
5 1
-2 1
1 0


Output

20
9
4


Input

4 1
-3 6 -1 2
1 2 3 1
1 -1


Output

5

Note

In the first example, to achieve the maximal value:

  * In the first query, you should select 1st, 3rd, and 4th ball. 
  * In the second query, you should select 3rd, 4th, 5th and 6th ball. 
  * In the third query, you should select 2nd and 4th ball. 



Note that there may be other ways to achieve the maximal value.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long INFLL = 1e18;
const int MAXN = 1e5 + 1e3;
class Cols {
  vector<int> lasuse;
  int cver, ccnt;

 public:
  Cols(int n) : lasuse(n, 0), cver(1), ccnt(0) {}
  void insert(int v) {
    assert(lasuse[v] < cver);
    lasuse[v] = cver;
    ccnt++;
  }
  void erase(int v) {
    lasuse[v] = cver - 1;
    ccnt--;
  }
  bool hasnot(int x) { return ccnt > 1 || (ccnt == 1 && lasuse[x] < cver); }
  bool empty() const { return ccnt == 0; }
  void clear() {
    cver++;
    ccnt = 0;
  }
  void swap(Cols &c2) {
    lasuse.swap(c2.lasuse);
    ::swap(cver, c2.cver);
    ::swap(ccnt, c2.ccnt);
  }
};
class Magic {
  long long v1, v2;
  Cols c1, c2;

 public:
  Magic(int n) : v1(-INFLL - 1), v2(-INFLL - 1), c1(n), c2(n) {}
  void erase(const long long &cv, int cc) {
    if (v2 == cv) {
      c2.erase(cc);
      if (c2.empty()) v2 = -INFLL - 1;
      return;
    }
    if (v1 == cv) {
      c1.erase(cc);
      if (c1.empty()) {
        v1 = -INFLL - 1;
        swap(v1, v2);
        c1.swap(c2);
      }
    }
  }
  void add(const long long &cv, int cc) {
    if (cv < v2) return;
    if (cv < v1) {
      if (v2 != cv) c2.clear();
      c2.insert(cc);
      v2 = cv;
      return;
    }
    if (v1 != cv) {
      c2.swap(c1);
      swap(v2, v1);
      c1.clear();
    }
    c1.insert(cc);
    v1 = cv;
  }
  long long get(int badc) {
    if (c1.hasnot(badc)) return v1;
    if (c2.hasnot(badc)) return v2;
    return -INFLL - 1;
  }
};
int main() {
  int n, q;
  while (scanf("%d%d", &n, &q) >= 1) {
    vector<int> vs(n), cs(n);
    for (int i = 0; i < n; i++) scanf("%d", &vs[i]);
    for (int i = 0; i < n; i++) scanf("%d", &cs[i]), cs[i]--;
    while (q-- > 0) {
      long long eqv, neqv;
      scanf("%I64d%I64d", &eqv, &neqv);
      Magic mgc(n);
      vector<long long> cdyn(n, -INFLL);
      for (int i = 0; i < n; i++) mgc.add(cdyn[i], i);
      long long ans = 0;
      for (int i = 0; i < n; i++) {
        int cc = cs[i];
        long long cans = cdyn[cc] + vs[i] * eqv;
        cans = max(cans, mgc.get(cc) + vs[i] * neqv);
        cans = max(cans, vs[i] * neqv);
        ans = max(ans, cans);
        mgc.erase(cdyn[cc], cc);
        cdyn[cc] = max(cdyn[cc], cans);
        mgc.add(cdyn[cc], cc);
      }
      printf("%I64d\n", ans);
    }
  }
  return 0;
}