#include <bits/stdc++.h>
using namespace std;
long long __gcd(long long a, long long b) {
  if (b == 0) return a;
  return __gcd(b, a % b);
}
void solve() {
  int a, b, c;
  int first, second, u;
  cin >> a >> b >> c >> first >> second;
  if (first > second) {
    u = min(b, a / 2);
    cout << u * first + min((a - 2 * u) / 2, c) * second << '\n';
  } else {
    u = min(c, a / 2);
    cout << u * second + min((a - 2 * u) / 2, b) * first << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
