#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int b, p, f;
    int h, c;
    cin >> b >> p >> f >> h >> c;
    if (b == 1) {
      cout << 0 << "\n";
      continue;
    }
    int price = 0;
    if (h >= c) {
      while (b > 1 && p) {
        price += h;
        b -= 2;
        p--;
      }
      while (b > 1 && f) {
        price += c;
        b -= 2;
        f--;
      }
    } else {
      while (b > 1 && f) {
        price += c;
        b -= 2;
        f--;
      }
      while (b > 1 && p) {
        price += h;
        b -= 2;
        p--;
      }
    }
    cout << price << "\n";
  }
}
