#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, b, c, bula, menco, kura;
  cin >> t;
  while (t--) {
    cin >> bula >> menco >> kura;
    cin >> b >> c;
    bula /= 2;
    if (b < c) {
      int xd = b;
      b = c;
      c = xd;
      xd = menco;
      menco = kura;
      kura = xd;
    }
    int ans = 0;
    if (menco >= bula) {
      ans = bula * b;
    } else {
      ans += menco * b;
      bula -= menco;
      if (kura >= bula) {
        ans += bula * c;
      } else {
        ans += kura * c;
      }
    }
    cout << ans << std::endl;
  }
  return 0;
}
