#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long powm(long long base, long long exp, long long mod = 1000000007) {
  long long ans = 1;
  while (exp) {
    if (exp & 1) ans = (ans * base) % mod;
    exp >>= 1, base = (base * base) % mod;
  }
  return ans;
}
long long dp[100005], v[100005], c[100005];
long long maxm1, maxm2;
int main() {
  long long n, q, a, b, ans, tmp1, tmp2;
  cin >> n >> q;
  for (long long i = 1; i < n + 1; i++) cin >> v[i];
  for (long long i = 1; i < n + 1; i++) cin >> c[i];
  while (q--) {
    cin >> a >> b, ans = maxm1 = maxm2 = 0;
    for (long long i = 1; i < 100005; i++) dp[i] = -1000111000111000111LL;
    for (long long i = 1; i < n + 1; i++) {
      tmp1 = max(dp[c[i]], dp[c[i]] + v[i] * a);
      if (maxm1 != c[i])
        tmp2 = dp[maxm1] + v[i] * b;
      else
        tmp2 = dp[maxm2] + v[i] * b;
      dp[c[i]] = max(tmp1, tmp2);
      if (maxm1 != c[i] and maxm2 != c[i]) {
        if (dp[maxm1] < dp[c[i]])
          maxm2 = maxm1, maxm1 = c[i];
        else if (dp[maxm2] < dp[c[i]])
          maxm2 = c[i];
      } else if (maxm2 == c[i]) {
        if (dp[maxm2] > dp[maxm1]) swap(maxm1, maxm2);
      }
    }
    for (long long i = 0; i < 100005; i++) ans = max(ans, dp[i]);
    cout << ans << endl;
  }
  return 0;
}
