#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, p, f, p_p, p_f, sum = 0;
    cin >> n >> p >> f >> p_p >> p_f;
    n /= 2;
    if (p_f > p_p) {
      swap(p, f);
      swap(p_p, p_f);
    }
    int tmp = min(n, p);
    n -= tmp;
    int tmp1 = min(n, f);
    cout << tmp * p_p + tmp1 * p_f << endl;
  }
  return 0;
}
