#include <bits/stdc++.h>
using namespace std;
pair<long long int, int> maxi, mini;
void update(long long int val, int color) {
  if (color != maxi.second && color != mini.second) {
    if (maxi.first <= val) {
      mini = maxi;
      maxi = make_pair(val, color);
    } else if (mini.first < val)
      mini = make_pair(val, color);
  } else if (color == maxi.second) {
    if (maxi.first <= val) maxi.first = val;
  } else if (color == mini.second) {
    if (maxi.first <= val) {
      mini = maxi;
      maxi = make_pair(val, color);
    } else if (mini.first < val)
      mini.first = val;
  }
}
long long int func(int n, int a, int b, int *color, int *v) {
  long long int dp[n + 2];
  int c[n + 2];
  fill(c, c + n + 2, 0);
  fill(dp, dp + n + 2, -10000000000000000LL);
  long long int ans = 0;
  maxi = make_pair(-10000000000000000LL, -1);
  mini = make_pair(-10000000000000000LL, -1);
  for (int i = 0; i < n; i++) {
    long long int temp1 = dp[color[i]];
    temp1 += (long long)a * (long long)v[i];
    if (c[color[i]] > 0) dp[color[i]] = max(temp1, dp[color[i]]);
    if (n - c[color[i]] > 0) {
      if (maxi.second != color[i])
        dp[color[i]] =
            max(maxi.first + (long long)b * (long long)v[i], dp[color[i]]);
      else
        dp[color[i]] =
            max(mini.first + (long long)b * (long long)v[i], dp[color[i]]);
    }
    dp[color[i]] = max(dp[color[i]], (long long)b * (long long)v[i]);
    c[color[i]]++;
    ans = max(ans, dp[color[i]]);
    update(dp[color[i]], color[i]);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  int c[n], v[n];
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) cin >> c[i];
  while (q--) {
    int a, b;
    cin >> a >> b;
    cout << func(n, a, b, c, v) << endl;
  }
  return 0;
}
