#include <bits/stdc++.h>
using namespace std;
int Q;
long N;
long long A, B;
long long Best[100005];
long long MaximumC[2], MaximumV[2];
long long C[100005], V[100005];
void in() {
  scanf("%ld %d", &N, &Q);
  for (long i = 0; i < N; i++) scanf("%I64d", &V[i]);
  for (long i = 0; i < N; i++) scanf("%I64d", &C[i]);
}
void updateMaximums(long long c, long long v) {
  if (v > MaximumV[0]) {
    if (c != MaximumC[0]) {
      MaximumV[1] = MaximumV[0];
      MaximumC[1] = MaximumC[0];
    }
    MaximumV[0] = v;
    MaximumC[0] = c;
    return;
  }
  if (v > MaximumV[1]) {
    MaximumV[1] = v;
    MaximumC[1] = c;
  }
}
long long query() {
  long long maxExcept;
  long long ans = 0;
  long long value_a, value_b;
  Best[0] = 0;
  MaximumC[0] = 0;
  MaximumV[0] = 0;
  for (long i = 1; i <= N; i++) Best[i] = -10000000000000000ll;
  for (long i = 0; i < N; i++) {
    value_a = Best[C[i]] + V[i] * A;
    value_b = (MaximumC[0] == C[i] ? MaximumV[1] : MaximumV[0]) + V[i] * B;
    if ((value_a > value_b ? value_a : value_b) > Best[C[i]]) {
      Best[C[i]] = (value_a > value_b ? value_a : value_b);
      ans = (ans > Best[C[i]] ? ans : Best[C[i]]);
      updateMaximums(C[i], Best[C[i]]);
    }
  }
  return ans;
}
void solve() {
  MaximumV[0] = MaximumV[1] = -10000000000000000ll;
  for (int i = 0; i < Q; i++) {
    scanf("%I64d %I64d", &A, &B);
    printf("%I64d\n", query());
  }
}
int main() {
  in();
  solve();
  return 0;
}
