#include <bits/stdc++.h>
int main() {
  long long int t, b, p, f, h, c, ma, mi, s = 0;
  scanf("%lld", &t);
  while (t--) {
    s = 0;
    scanf("%lld %lld %lld %lld %lld", &b, &p, &f, &h, &c);
    b = b / 2;
    if (h >= c) {
      if (b >= p && b != 0) {
        s += p * h;
        b -= p;
      } else if (b < p && b != 0) {
        s += b * h;
        b = 0;
      }
      if (b >= f && b != 0) {
        s += f * c;
        b -= f;
      } else if (b < f && b != 0) {
        s += b * c;
        b = 0;
      }
    } else if (h < c) {
      if (b >= f && b != 0) {
        s += f * c;
        b -= f;
      } else if (b < f && b != 0) {
        s += b * c;
        b = 0;
      }
      if (b >= p && b != 0) {
        s += p * h;
        b -= p;
      } else if (b < p && b != 0) {
        s += b * h;
        b = 0;
      }
    }
    printf("%lld\n", s);
  }
}
