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