#include <bits/stdc++.h>
using namespace std;
const int inf = 1e09 + 31;
const int mxn = 1e5;
int v[mxn + 5], c[mxn + 5];
long long a, b, mx = 0, mx2 = 0, mxi = -1, mx2i = -1, t[mxn + 5];
inline long long gmx(int i) { return ((i == mxi) ? mx2 : mx); }
inline void update(long long val, int p) {
  if (val >= mx) {
    if (p != mxi) {
      mx2 = mx;
    }
    mx = val;
    mxi = p;
  } else if (val >= mx2 && p != mxi) {
    mx2 = val;
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int l = 0; l < q; l++) {
    cin >> a >> b;
    memset(t, 0, sizeof(t[0]) * (n + 4));
    mx = 0, mx2 = 0, mxi = -1, mx2i = -1;
    for (int i = n - 1; i >= 0; i--) {
      long long temp = max(gmx(c[i]), t[c[i]]);
      update(temp + v[i] * b, c[i]);
      t[c[i]] = max(t[c[i]], temp + v[i] * a);
    }
    cout << mx << '\n';
  }
}
