#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T max3(T a, T b, T c) {
  a = a > b ? a : b;
  return a > c ? a : c;
}
int n, q;
int c1, c2;
long long dp[100005];
long long va[100005];
long long vb[100005];
long long v[100005];
int c[100005];
inline void update(long long a, long long &b, long long &c, int i) {
  if (a >= b) {
    if (i == c1)
      b = a;
    else {
      c = b;
      b = a;
      c2 = c1;
      c1 = i;
    }
  } else if (a > c) {
    c = a;
    c2 = i;
  }
}
int main() {
  int i, k, c_i;
  long long a, b;
  long long first, sec, t;
  cin >> n >> q;
  for (i = 0; i < n; i++) cin >> v[i];
  for (i = 0; i < n; i++) cin >> c[i];
  for (k = 0; k < q; k++) {
    cin >> a >> b;
    for (i = 0; i < n; i++) {
      va[i] = v[i] * a;
      vb[i] = v[i] * b;
      dp[i + 1] = LLONG_MIN;
    }
    first = 0;
    sec = 0;
    c1 = -1;
    c2 = -1;
    for (i = 0; i < n; i++) {
      c_i = c[i];
      if (c_i != c1)
        t = max(dp[c_i], first + vb[i]);
      else
        t = max(dp[c_i], sec + vb[i]);
      if (dp[c_i] == LLONG_MIN)
        dp[c_i] = t;
      else
        dp[c_i] = max(t, dp[c_i] + va[i]);
      update(dp[c_i], first, sec, c_i);
    }
    cout << (first > 0 ? first : 0) << endl;
  }
  return 0;
}
