#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  fast();
  int t, b, p, f, h, c;
  cin >> t;
  while (t--) {
    cin >> b >> p >> f;
    cin >> h >> c;
    int bun = b / 2;
    if (bun >= p + f) {
      cout << p * h + f * c << endl;
    } else {
      if (c > h) {
        if (bun >= f) {
          cout << f * c + (bun - f) * h << endl;
        } else {
          cout << bun * c << endl;
        }
      } else {
        if (bun >= p) {
          cout << p * h + (bun - p) * c << endl;
        } else {
          cout << bun * h << endl;
        }
      }
    }
  }
  return 0;
}
