#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int b, p, f, h, c;
    cin >> b >> p >> f >> h >> c;
    long sum = 0;
    if (b == 1) {
      cout << 0 << "\n";
    } else {
      if (h > c) {
        while (p != 0 && b > 1) {
          sum += h;
          p--;
          b -= 2;
        }
        while (f != 0 && b > 1) {
          sum += c;
          f--;
          b -= 2;
        }
      } else if (c > h) {
        while (f != 0 && b > 1) {
          sum += c;
          f--;
          b -= 2;
        }
        while (p != 0 && b > 1) {
          sum += h;
          p--;
          b -= 2;
        }
      } else {
        if (f >= p) {
          while (f != 0 && b > 1) {
            b -= 2;
            sum += c;
            f--;
          }
          while (p != 0 && b > 1) {
            sum += h;
            p--;
            b -= 2;
          }
        } else {
          while (p != 0 && b > 1) {
            sum += h;
            p--;
            b -= 2;
          }
          while (f != 0 && b > 1) {
            b -= 2;
            sum += c;
            f--;
          }
        }
      }
      cout << sum << "\n";
    }
  }
}
