#include <bits/stdc++.h>
int max(int a, int b) { return a > b ? a : b; }
int main() {
  int t, b, p, f, h, c;
  scanf("%d", &t);
  while (t) {
    int profit = 0;
    scanf("%d %d %d", &b, &p, &f);
    scanf("%d %d", &h, &c);
    if (b / 2 >= p + f) {
      profit = p * h + f * c;
    } else {
      int m = max(h, c);
      int m1;
      if (m == h)
        m1 = p;
      else
        m1 = f;
      if (b / 2 > m1) {
        if (m == h)
          profit = p * h + (b / 2 - p) * c;
        else
          profit = f * c + (b / 2 - f) * h;
      } else {
        if (m == h)
          profit = b / 2 * h;
        else
          profit = b / 2 * c;
      }
    }
    printf("%d\n", profit);
    t--;
  }
}
