#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int b, f, p, h, c, money = 0;
    scanf("%d %d %d %d %d", &b, &p, &f, &h, &c);
    b /= 2;
    if (h > c) {
      money = min(b, p) * h;
      b -= min(b, p);
      money += min(b, f) * c;
    } else {
      money = min(b, f) * c;
      b -= min(b, f);
      money += min(b, p) * h;
    }
    printf("%d\n", money);
  }
}
