#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  ;
  long long int n, q, a, b;
  cin >> n >> q;
  long long int v[n + 1], c[n + 1];
  for (int i = 1; i <= n; i++) cin >> v[i];
  for (int i = 1; i <= n; i++) cin >> c[i];
  while (q--) {
    vector<long long int> dp(n + 1, -100000000000000000);
    long long int m1, m2 = 0, otherMax = -1;
    long long int m1_idx, m2_idx = -1;
    cin >> a >> b;
    dp[c[1]] = v[1] * b;
    m1 = dp[c[1]], m1_idx = c[1];
    long long int ans = -100000000000000000;
    for (int i = 2; i <= n; i++) {
      if (m1_idx == c[i])
        otherMax = m2;
      else
        otherMax = m1;
      if (dp[c[i]] != -100000000000000000)
        dp[c[i]] = max(dp[c[i]],
                       max(dp[c[i]] + v[i] * a, max(0LL, otherMax) + v[i] * b));
      else
        dp[c[i]] = max(0LL, otherMax) + v[i] * b;
      if (dp[c[i]] >= m1 and m1_idx != c[i]) {
        m2 = m1, m2_idx = m1_idx;
        m1 = dp[c[i]], m1_idx = c[i];
      } else if (dp[c[i]] >= m1 and m1_idx == c[i]) {
        m1 = dp[c[i]], m1_idx = c[i];
      } else if (dp[c[i]] > m2)
        m2 = dp[c[i]], m2_idx = c[i];
      ans = max(ans, dp[c[i]]);
    }
    if (ans < 0)
      cout << "0\n";
    else
      cout << ans << endl;
  }
}
