#include <bits/stdc++.h>   using namespace std;   const long long inf = (long long)4e18;   int n, q;   long long c[110000];   long long v[110000];   long long d[110000];   int u[110000];   int main() {     ios::sync_with_stdio(0);     cin >> n >> q;     for (int i = 0; i < n; ++i) cin >> v[i];     for (int i = 0; i < n; ++i) cin >> c[i];     while (q--) {       long long a, b;       cin >> a >> b;       for (int i = 0; i <= n; ++i) d[i] = -inf;       long long et = 0;       pair<long long, int> m1 = make_pair(-inf, -1);       pair<long long, int> m2 = make_pair(-inf, -1);       for (int i = 0; i < n; ++i) {         long long ans = max(v[i] * b, d[c[i]]);         ans = max(ans, d[c[i]] + v[i] * a);         if (m1.second != c[i])           ans = max(ans, m1.first + v[i] * b);         else           ans = max(ans, m2.first + v[i] * b);         if (ans > m1.first)           if (m1.second != c[i])             m2 = m1, m1 = make_pair(ans, c[i]);           else             m1.first = ans;         else if (ans > m2.first && c[i] != m1.second)           m2 = make_pair(ans, c[i]);         d[c[i]] = max(d[c[i]], ans);         et = max(et, ans);       }       cout << et <<   n ;     }   }   