#include <bits/stdc++.h>
using namespace std;
void smeni(int &a, int &b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}
int funk(int b, int p, int f, int h, int c) {
  if (b <= 1 || p == 0 || f == 0) return 0;
  int suma = 0;
  if (c > h) {
    smeni(c, h);
    smeni(p, f);
  }
  if (c == h) {
    while (b > 1 && p > 0) {
      suma = suma + h;
      b = b - 2;
      p--;
    }
  } else {
    while (b > 1 && p > 0) {
      suma = suma + h;
      p--;
      b = b - 2;
    }
  }
  if (b - 2 * f > 1) {
    suma = suma + f * c;
  } else {
    while (b > 1 && f > 0) {
      suma = suma + c;
      b = b - 2;
      f--;
    }
  }
  return suma;
}
int main() {
  int t;
  cin >> t;
  int b, p, f;
  int h, c;
  queue<int> red;
  for (int i = 0; i < t; i++) {
    cin >> b >> p >> f;
    cin >> h >> c;
    red.push(funk(b, p, f, h, c));
  }
  while (!red.empty()) {
    cout << red.front() << endl;
    red.pop();
  }
  return 0;
}
