#include <bits/stdc++.h>
using namespace std;
int main() {
  long long T, a, b, c, d, e;
  cin >> T;
  while (T--) {
    scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &d, &e);
    long long ans = 0;
    if (e > d) {
      ans += min(a / 2, c) * e;
      a -= min(a / 2, c) * 2;
      ans += min(a / 2, b) * d;
    } else {
      ans += min(a / 2, b) * d;
      a -= min(a / 2, b) * 2;
      ans += min(a / 2, c) * e;
    }
    printf("%lld\n", ans);
  }
}
