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