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