#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t, b, p, f, h, c, pro;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> b >> p >> f;
    cin >> h >> c;
    pro = 0;
    if (h >= c) {
      while (b >= 2 && p >= 1) {
        p--;
        b = b - 2;
        pro += h;
      }
      while (b >= 2 && f >= 1) {
        f--;
        b = b - 2;
        pro += c;
      }
    } else {
      while (b >= 2 && f >= 1) {
        f--;
        b = b - 2;
        pro += c;
      }
      while (b >= 2 && p >= 1) {
        p--;
        b = b - 2;
        pro += h;
      }
    }
    cout << pro << "\n";
  }
}
