#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10;
const long long I = 1e18 + 10;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long b, p, f, h, c;
    cin >> b >> p >> f >> h >> c;
    long long sum = 0;
    if (h >= c) {
      while ((p-- > 0) && (b > 1)) b -= 2, sum += h;
      while ((f-- > 0) && (b > 1)) b -= 2, sum += c;
    } else {
      while ((f-- > 0) && (b > 1)) b -= 2, sum += c;
      while ((p-- > 0) && (b > 1)) b -= 2, sum += h;
    }
    cout << sum << endl;
  }
}
