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