#include <bits/stdc++.h>
using namespace std;
const long long inf = -(long long)1e18;
const int N = 100010;
int c[N], n;
long long dp[N], v[N];
void work() {
  long long a, b, fir = 0, sec = inf, tmp1, tmp2;
  scanf("%I64d%I64d", &a, &b);
  for (int i = 0; i <= n; ++i) dp[i] = inf;
  for (int i = 0; i < n; ++i) {
    tmp1 = tmp2 = inf;
    if (dp[c[i]] != inf) tmp1 = dp[c[i]] + v[i] * a;
    if (fir > dp[c[i]])
      tmp2 = fir + v[i] * b;
    else
      tmp2 = sec + v[i] * b;
    tmp1 = max(tmp1, tmp2);
    if (tmp1 > dp[c[i]]) {
      if (tmp1 > sec)
        if (dp[c[i]] == fir)
          fir = tmp1;
        else {
          sec = min(fir, tmp1);
          fir = max(fir, tmp1);
        }
      dp[c[i]] = tmp1;
    }
  }
  printf("%I64d\n", fir);
}
int main() {
  int q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; ++i) scanf("%I64d", v + i);
  for (int i = 0; i < n; ++i) scanf("%d", c + i);
  for (int i = 0; i < q; ++i) work();
}
