#include <bits/stdc++.h>
long long int max(long long int a, long long int b) { return (a > b) ? a : b; }
long long int maximize(const int *c, const int *v, const int n,
                       const long long int a, const long long int b) {
  long long int best[112345] = {};
  long long int change_best1 = 0, change_best2 = 0;
  int col1 = 0, col2 = 0;
  long long int ans = 0;
  int i;
  for (i = n - 1; i >= 0; --i) {
    int col = c[i];
    long long int val = v[i] * b;
    long long int tail =
        max(best[col], ((col != col1) ? change_best1 : change_best2));
    ans = max(ans, val + tail);
    best[col] = max(best[col], v[i] * a + tail);
    if (val + tail >= change_best1) {
      if (col1 != col) {
        change_best2 = change_best1;
        col2 = col1;
      }
      change_best1 = val + tail;
      col1 = col;
    } else if ((val + tail > change_best2) && (col != col1)) {
      change_best2 = val + tail;
      col2 = col;
    }
  }
  return ans;
}
int main() {
  int i, q, n;
  int v[112345], c[112345];
  scanf("%d", &n);
  scanf("%d", &q);
  for (i = 0; i < n; ++i) scanf("%d", &v[i]);
  for (i = 0; i < n; ++i) scanf("%d", &c[i]);
  while (q--) {
    long long int a, b;
    scanf("%I64d", &a);
    scanf("%I64d", &b);
    printf("%I64d\n", maximize(c, v, n, a, b));
  }
  return 0;
}
