#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long b, p, f, pb, pf, rb, rf, sum = 0, m;
    long long mx, mn;
    cin >> b >> p >> f;
    cin >> pb >> pf;
    mx = max(pb, pf);
    b /= 2;
    if (mx == pb) {
      mn = min(b, p);
      sum += (mn * pb);
      mn = b - mn;
      mn = min(mn, f);
      sum += (mn * pf);
    } else {
      mn = min(b, f);
      sum += (mn * pf);
      mn = b - mn;
      mn = min(mn, p);
      sum += (mn * pb);
    }
    cout << sum << endl;
  }
}
