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