#include <bits/stdc++.h>
using namespace std;
int t, b, p, f, h, c;
int a[100];
int main() {
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> b >> p >> f >> h >> c;
    if (h > c) {
      while (b >= 2 && p >= 1) {
        a[i] += h;
        b -= 2;
        p--;
      }
      while (b >= 2 && f >= 1) {
        a[i] += c;
        b -= 2;
        f--;
      }
    } else {
      while (b >= 2 && f >= 1) {
        a[i] += c;
        b -= 2;
        f--;
      }
      while (b >= 2 && p >= 1) {
        a[i] += h;
        b -= 2;
        p--;
      }
    }
  }
  for (int i = 0; i < t; i++) cout << a[i] << endl;
  return 0;
}
