#include <bits/stdc++.h>
using namespace std;
int main() {
  short t;
  cin >> t;
  int buns;
  int beef;
  int chicken;
  int chic_price;
  int ham_price;
  int profit;
  while (t--) {
    profit = 0;
    cin >> buns >> beef >> chicken;
    cin >> ham_price >> chic_price;
    if (ham_price >= chic_price) {
      int t = min(beef, (buns / 2));
      profit += (t * ham_price);
      buns -= (2 * t);
      int p = min(chicken, (buns / 2));
      profit += (p * chic_price);
    } else {
      int t = min(chicken, (buns / 2));
      profit += (t * chic_price);
      buns -= (2 * t);
      int p = min(beef, (buns / 2));
      profit += (p * ham_price);
    }
    cout << profit << "\n";
  }
}
