#include <bits/stdc++.h>
using namespace std;
int main() {
  int test;
  cin >> test;
  while (test--) {
    int bun, beef, chicks, hp, cp, count1 = 0, count2 = 0;
    cin >> bun >> beef >> chicks >> hp >> cp;
    bun /= 2;
    if (hp >= cp) {
      count1 = min(bun, beef);
      bun -= count1;
      if (bun != 0) {
        count2 = min(bun, chicks);
      }
    } else {
      count2 = min(bun, chicks);
      bun -= count2;
      if (bun != 0) {
        count1 = min(bun, beef);
      }
    }
    cout << count1 * hp + count2 * cp << endl;
  }
}
