#include <bits/stdc++.h>
using namespace std;
int C[1 << 20];
int V[1 << 20];
long long R[1 << 20];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  int i, j;
  for (i = (0); i < (n); ++i) scanf("%d", &V[i]);
  for (i = (0); i < (n); ++i) scanf("%d", &C[i]);
  for (i = (0); i < (q); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    for (j = (0); j < (n + 1); ++j) R[j] = -(1LL << 60);
    R[0] = 0;
    long long x = 0;
    long long y = 1;
    for (j = (0); j < (n); ++j) {
      int c = C[j];
      long long v = V[j];
      long long r = max(R[c] + a * v, R[x == c ? y : x] + b * v);
      if (r > R[c]) {
        R[c] = r;
        if (c == x || c == y) {
          if (R[x] < R[y]) swap(x, y);
        } else {
          if (r > R[x]) {
            y = x;
            x = c;
          } else if (r > R[y]) {
            y = c;
          }
        }
      }
    }
    printf("%lld\n", R[x]);
  }
  return 0;
};
