#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int b, p, f, h, c;
    cin >> b >> p >> f;
    cin >> h >> c;
    int cost = 0;
    while (b > 1 && (p > 0 || f > 0)) {
      if ((h > c && p > 0) || (f == 0 && p > 0)) {
        b -= 2;
        p--;
        cost += h;
      } else if ((c >= h && f > 0) || (p == 0 && f > 0)) {
        b -= 2;
        f--;
        cost += c;
      }
    }
    cout << cost << endl;
  }
  return 0;
}
