#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    int b, p, f, a1, a2;
    cin >> b >> p >> f;
    cin >> a1 >> a2;
    int maxx = 0;
    int ansx = b / 2;
    for (int i = 0; i <= min(p, ansx); i++) {
      int sum = 0;
      sum += i * a1;
      int j = ansx - i;
      sum += min(j, f) * a2;
      maxx = max(maxx, sum);
    }
    cout << maxx << endl;
  }
  return 0;
}
