#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, b, p, f, h, c, m;
  cin >> t;
  while (t--) {
    cin >> b >> p >> f >> h >> c;
    m = 0;
    if (h > c) {
      m += min(p, b / 2) * h;
      b -= min(p, b / 2) * 2;
      m += min(f, b / 2) * c;
    } else {
      m += min(f, b / 2) * c;
      b -= min(f, b / 2) * 2;
      m += min(p, b / 2) * h;
    }
    cout << m << endl;
  }
  return 0;
}
