#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  int s = 0, o = 0;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int n, m;
    scanf("%d %d", &n, &m);
    if (m < n) {
      while (a > 1 && b > 0) {
        a -= 2;
        b--;
        s += n;
      }
      while (a > 1 && c > 0) {
        a -= 2;
        c--;
        s += m;
      }
    } else if (m == n && b > c) {
      while (a > 1 && b > 0) {
        a -= 2;
        b--;
        s += n;
      }
      while (a > 1 && c > 0) {
        a -= 2;
        c--;
        s += m;
      }
    } else {
      while (a > 1 && c > 0) {
        a -= 2;
        c--;
        s += m;
      }
      while (a > 1 && b > 0) {
        a -= 2;
        b--;
        s += n;
      }
    }
    cout << s << endl;
    s = 0;
  }
  return 0;
}
