#include <bits/stdc++.h>
using namespace std;
void TProfit(int b, int p, int f, int h, int c) {
  if (b < 2) {
    cout << "0" << endl;
    return;
  }
  int profit = 0, burger = b / 2;
  if (h > c) {
    if (burger <= p) {
      profit = burger * h;
    } else {
      if ((burger - p) < f) {
        profit = (p * h) + ((burger - p) * c);
      } else {
        profit = (p * h) + (f * c);
      }
    }
  } else {
    if (burger <= f) {
      profit = burger * c;
    } else {
      if ((burger - f) < p) {
        profit = (f * c) + ((burger - f) * h);
      } else {
        profit = (f * c) + (p * h);
      }
    }
  }
  cout << profit << endl;
  return;
}
int main() {
  int t, b, p, f, h, c;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> b >> p >> f;
    cin >> h >> c;
    TProfit(b, p, f, h, c);
  }
}
