#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
long long dp[maxn];
int n, ask;
int v[maxn], c[maxn];
long long a, b;
struct node {
  int c;
  long long v;
  node() {}
  node(long long v, int c) : c(c), v(v) {}
};
const long long inf = (1LL << 50);
node m[2];
inline void insert(long long v, int c) {
  bool ok = 0;
  for (int i = 0; i < 2; i++) {
    if (m[i].c == c) {
      ok = 1;
      m[i].v = v;
    }
  }
  if (ok) return;
  node t = node(v, c);
  for (int i = 0; i < 2; i++) {
    if (t.v > m[i].v) swap(t, m[i]);
  }
}
int main() {
  while (scanf("%d%d", &n, &ask) == 2) {
    for (int i = 0; i < n; i++) scanf("%d", &v[i]);
    for (int i = 0; i < n; i++) scanf("%d", &c[i]);
    while (ask--) {
      fill(dp, dp + n + 1, -(1LL << 60));
      dp[0] = 0;
      int ca = 0, cb = 0;
      scanf("%I64d%I64d", &a, &b);
      for (int i = 0; i < n; i++) {
        long long nv = dp[c[i]] + a * v[i];
        if (cb != c[i]) nv = max(nv, dp[cb] + b * v[i]);
        if (ca != c[i]) nv = max(nv, dp[ca] + b * v[i]);
        if (ca != c[i]) {
          if (dp[ca] < nv)
            cb = ca, ca = c[i];
          else if (dp[cb] < nv)
            cb = c[i];
        }
        dp[c[i]] = max(dp[c[i]], nv);
      }
      printf("%I64d\n", dp[ca]);
    }
  }
  return 0;
}
