#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  int a[t + 10];
  for (int i = 0; i < t; i++) {
    long int b, p, f, c, h, c1 = 0, c2 = 0;
    cin >> b >> p >> f;
    cin >> h >> c;
    b = b / 2;
    if (b == 0) {
      cout << 0 << endl;
      continue;
    }
    if (h > c) {
      if (b >= p) {
        c1 += (p * h);
        b -= p;
        if (f >= b) {
          c1 += b * c;
        } else {
          c1 += f * c;
        }
      } else {
        c1 += b * h;
      }
    } else {
      if (b >= f) {
        b -= f;
        c1 += c * f;
        if (b > p) {
          c1 += p * h;
        } else {
          c1 += b * h;
        }
      } else {
        c1 += b * c;
      }
    }
    cout << c1 << endl;
    c1 = 0;
  }
}
