#include <bits/stdc++.h>
using namespace std;
int T;
int main() {
  cin >> T;
  while (T--) {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if (d < e) swap(d, e), swap(b, c);
    cout << std::min(a / 2, b) * d + std::min(std::max(a - 2 * b, 0) / 2, c) * e
         << endl;
  }
  return 0;
}
