#include <bits/stdc++.h>
using namespace std;
long long n, t, b, zah, zac, h, c;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cin >> t;
  while (t--) {
    cin >> b >> zah >> zac;
    cin >> h >> c;
    long long res = 0;
    if (h >= c) {
      long long temp = min(b / 2, zah);
      res += temp * h;
      b -= 2 * temp;
      res += min(b / 2, zac) * c;
    } else {
      long long temp = min(b / 2, zac);
      res += temp * c;
      b -= 2 * temp;
      res += min(b / 2, zah) * h;
    }
    cout << res << endl;
  }
  return 0;
}
