#include<bits/stdc++.h>
using namespace std;
using namespace chrono;
using ll = long long;
const bool generate_test = false;
const bool validate_test = true;
#define lcm(x,y) (x/__gcd(x,y)*y)
ll n, x, a, y, b, k; vector<ll> price;
// Acceped solution written by: ek3ru8m4@codeforces.com
ll ek3ru8m4_solution() {
ll a1, x1, b1, y1, j = 1, c1 = 0, c2 = 0, c3 = 0, l = 0;
if (x < y)
a1 = b, x1 = y, b1 = a, y1 = x;
else
a1 = a, x1 = x, b1 = b, y1 = y;
for (x1 -= y1; l < k and j <= n; ++j) {
if (j%a1 == 0 or j%b1 == 0)
l += price[c3++] * y1;
if (j%a1 == 0)
l += price[c2++] * x1;
if (j%a1 == 0 && j%b1 == 0)
l += price[c1++] * y1; }
return l < k? -1: (j-1); }
// Random Test-Case Generator
template<typename Int>
struct random_variable: mt19937_64 {
random_variable() : mt19937_64(steady_clock::now().time_since_epoch().count()) {}
Int value(Int u, Int v) { return uniform_int_distribution<Int>(u,v)(*this); } };
random_variable<ll> Random;
void generate_test_case(ll N, ll P, ll Q) {
price.resize(n = N);
for (auto &q: price)
q = Random.value(1,P);
sort(price.rbegin(),price.rend());
const ll sum = Random.value(2,100);
x = Random.value(1,sum-1), y = sum-x,
a = Random.value(1,n),
b = Random.value(1,n),
k = Random.value(1,Q); }
void write_test_case() {
cout << 1 << endl << n << endl;
for (ll i = 0; i < n; ++i)
cout << 100*price[i] << ' ';
cout << endl << x << ' ' << a << endl << y << ' ' << b << endl << k; }
// Solution written by rpkv@codeforces.com
typedef long double ld;
typedef pair<ll,ll> pll;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,b,a) for(int i=b;i>a;i--)
#define FORDE(i,b,a) for(ll i=b;i>=a;i--)
#define debug(x) cout<< '>'<<#x<<" : "<<x<<"\n";
#define debug2(x,y) cout<< '>'<<#x<<" : "<<x<<"\n"; cout<< '>'<<#y<<" : "<<y<<"\n";
#define debug3(x,y,z) cout<< '>'<<#x<<" : "<<x<<"\n"; cout<< '>'<<#y<<" : "<<y<<"\n";cout<< '>'<<#z<<" : "<<z<<"\n";
#define umap unordered_map
#define uset unordered_set
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define in insert
#define s second
#define f first
#define nn cout<<"\n"
#define pb push_back
#define testcase int t;cin>>t;while(t--)
#define gcd(a,b) __gcd(a,b)
#define maxv INT_MAX
#define minv INT_MIN
#define MOD 1000000007
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define here cout<<"I'm here\n";
#define flush fflush(stdout);
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
template<class T> void dispvector(vector<T> v){for(int i=0;i<v.size();i++) cout<<v[i]<<" "; nn;}
template<class T> void disparray(T *v, int n){for(int i=0;i<n;i++) cout<<v[i]<<" "; nn;}
template<class T> int sizeofarr(T *v){return sizeof(v)/sizeof(T);}
void read_test_case() {
cin >> n, price.resize(n);
for (auto &q: price)
cin >> q, q /= 100;
sort(price.rbegin(),price.rend());
cin >> x >> a >> y >> b >> k; }
ll rpkv_solution() {
queue<ll> price1q;
queue<ll> price2q;
queue<ll> price3q;
ll cost = 0;
ll p1 = x+y;
ll p2,p3;
ll mlcm = lcm(a,b);
ll ans = -1;
if(x > y){
p2 = x;
p3 = y;
ll idx = 0;
FOR(i,0,n) {
if((i+1)%mlcm == 0){
if(price2q.size() == 0 && price3q.size() == 0){
cost += 1ll * price[idx] * p1;
idx++;
}
else if(price2q.size()== 0){
cost += 1ll * price3q.front() * (p1-p3);
price3q.pop();
price3q.push(price[idx]);
idx++;
}
else{
cost += 1ll * price2q.front() * (p1-p2);
price2q.pop();
if(price3q.size() == 0){
price2q.push(price[idx]);
cost += 1ll * price[idx]*p2;
idx++;
}else{
price2q.push(price3q.front());
cost += 1ll * price3q.front() * (p2-p3);
price3q.pop();
price3q.push(price[idx]);
cost += 1ll * price[idx]*p3;
idx++;
}
}
if(cost >= k){
ans = i+1;
break;
}
}else if((i+1)%a == 0){
if(price3q.size() == 0){
price2q.push(price[idx]);
cost += 1ll * price[idx]*p2;
idx++;
}else{
price2q.push(price3q.front());
cost += 1ll * price3q.front() * (p2-p3);
price3q.pop();
price3q.push(price[idx]);
cost += 1ll * price[idx]*p3;
idx++;
}
if(cost >= k){
ans = i+1;
break;
}
}else if((i+1)%b == 0){
price3q.push(price[idx]);
cost += 1ll * price[idx]*p3;
idx++;
if(cost >= k){
ans = i+1;
break;
}
}
}
}
else{
p2 = y;
p3 = x;
ll idx = 0;
FOR(i,0,n) {
if((i+1)%mlcm == 0){
if(price2q.size() == 0 && price3q.size() == 0){
cost += 1ll * price[idx] * p1;
idx++;
}
else if(price2q.size()== 0){
cost += 1ll * price3q.front() * (p1-p3);
price3q.pop();
price3q.push(price[idx]);
idx++;
}
else{
cost += 1ll * price2q.front() * (p1-p2);
price2q.pop();
if(price3q.size() == 0){
price2q.push(price[idx]);
cost += 1ll * price[idx]*p2;
idx++;
}else{
price2q.push(price3q.front());
cost += 1ll * price3q.front() * (p2-p3);
price3q.pop();
price3q.push(price[idx]);
cost += 1ll * price[idx]*p3;
idx++;
}
}
if(cost >= k){
ans = i+1;
break;
}
}else if((i+1)%b == 0){
if(price3q.size() == 0){
price2q.push(price[idx]);
cost += 1ll * price[idx]*p2;
idx++;
}else{
price2q.push(price3q.front());
cost += 1ll * price3q.front() * (p2-p3);
price3q.pop();
price3q.push(price[idx]);
cost += 1ll * price[idx]*p3;
idx++;
}
if(cost >= k){
ans = i+1;
break;
}
}else if((i+1)%a == 0){
price3q.push(price[idx]);
cost += 1ll * price[idx]*p3;
idx++;
if(cost >= k){
ans = i+1;
break;
}
}
}
}
return ans;
}
int main() {
if (generate_test) {
do
generate_test_case(10,100,1000);
while (ek3ru8m4_solution() == rpkv_solution());
write_test_case(); }
else if (validate_test) {
testcase {
read_test_case(),
write_test_case(),
cout << endl << "ek3ru8m4's solution = " << ek3ru8m4_solution(),
cout << endl << "rpkv's solution = " << rpkv_solution(); } }
else {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
FastIO;
testcase{ read_test_case(), cout << rpkv_solution() <<"\n"; } } }