#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) {
    lasuse[v] = cver;
    ccnt++;
  }
  void erase(int v) {
    assert(ccnt > 0);
    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 - 2), 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;
      assert(v1 > v2);
      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];
        assert(0 <= cc && cc < n);
        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);
      for (int i = 0; i < n; i++) mgc.erase(cdyn[i], i);
    }
  }
  return 0;
}
