#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
const long long inf = 1e17;
long long v[N];
long long c[N];
long long dp[N];
bool mark[N];
long long n, q;
long long a, b;
void solver() {
  cin >> a >> b;
  long long max1 = 0;
  long long color1 = 0;
  long long max2 = 0;
  long long color2 = 1;
  for (long long i = 0; i < N; i++) {
    dp[i] = -inf;
    mark[i] = 0;
  }
  for (long long i = 0; i < n; i++) {
    long long color = c[i];
    long long value = v[i];
    long long maxi = max1;
    if (color1 == color) {
      maxi = max2;
    }
    if (mark[color]) {
      dp[color] = max(dp[color], dp[color] + value * a);
    }
    dp[color] = max(dp[color], maxi + value * b);
    mark[color] = true;
    if (color != color1 && color != color2) {
      if (dp[color] > max1) {
        max2 = max1;
        color2 = color1;
        max1 = dp[color];
        color1 = color;
        continue;
      }
      if (dp[color] > max2) {
        max2 = dp[color];
        color2 = color;
      }
    }
    if (color == color1) {
      max1 = dp[color];
      color1 = color;
    }
    if (color == color2) {
      max2 = dp[color];
      if (max2 > max1) {
        swap(max2, max1);
        swap(color1, color2);
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
}
int main() {
  cin >> n >> q;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (long long i = 0; i < q; i++) {
    solver();
  }
}
