#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    unsigned int buns, beef, chicken;
    cin >> buns >> beef >> chicken;
    unsigned int hamburgers, chickenBurgers;
    hamburgers = 0;
    chickenBurgers = 0;
    unsigned int h, c;
    cin >> h >> c;
    if (h > c) {
      while (buns >= 2 && beef) {
        hamburgers++;
        buns -= 2;
        beef--;
      }
      while (buns >= 2 && chicken) {
        chickenBurgers++;
        buns -= 2;
        chicken--;
      }
    } else {
      while (buns >= 2 && chicken) {
        chickenBurgers++;
        buns -= 2;
        chicken--;
      }
      while (buns >= 2 && beef) {
        hamburgers++;
        buns -= 2;
        beef--;
      }
    }
    cout << chickenBurgers * c + hamburgers * h << endl;
  }
}
