#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979;
int n, q;
long long a, b;
long long arr[100001];
long long col[100001];
long long dp[100002];
long long notthat[100002];
long long INF = 1ll << 62;
long long solve() {
  vector<pair<long long, long long>> Maxs(3);
  Maxs[1].second = Maxs[0].second = -INF;
  for (int i = 1; i <= n; ++i) {
    dp[i] = -INF;
  }
  for (int i = 1; i <= n; ++i) {
    int k = 0;
    if (Maxs[0].first == col[i]) k = 1;
    if (dp[col[i]] == -INF) {
      dp[col[i]] = arr[i] * b;
      if (Maxs[k].second != -INF)
        dp[col[i]] = max(dp[col[i]], Maxs[k].second + arr[i] * b);
    } else {
      dp[col[i]] = max(max(arr[i] * b, dp[col[i]]), dp[col[i]] + arr[i] * a);
      if (Maxs[k].second != -INF)
        dp[col[i]] = max(dp[col[i]], Maxs[k].second + arr[i] * b);
    }
    if (Maxs[0].first == col[i]) {
      Maxs[0].first = col[i];
      Maxs[0].second = dp[col[i]];
    } else if (Maxs[1].first == col[i]) {
      Maxs[1].first = col[i];
      Maxs[1].second = dp[col[i]];
    } else {
      Maxs[2].first = col[i];
      Maxs[2].second = dp[col[i]];
    }
    if (Maxs[2].second > Maxs[1].second) swap(Maxs[1], Maxs[2]);
    if (Maxs[1].second > Maxs[0].second) swap(Maxs[0], Maxs[1]);
    if (Maxs[2].second > Maxs[1].second) swap(Maxs[1], Maxs[2]);
    Maxs[2].second = -INF;
    Maxs[2].first = 0;
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, dp[i]);
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d", &arr[i]);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d", &col[i]);
  }
  for (int i = 1; i <= q; ++i) {
    scanf("%I64d %I64d", &a, &b);
    printf("%I64d\n", solve());
  }
  return 0;
}
