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