#include <bits/stdc++.h>

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007

using namespace std;
#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";

bool check(ll a, ll x, ll b, ll y, ll k, ll n, vl p){
	vl v, ps;
	for (ll i = 0; i < n; ++i){
		ps.pb(0);
		v.pb(0);
	}
	ll g = (a*b)/__gcd(a, b);
	ll j = 0;
	for (ll i = g; i <= n; i+=g){
		v[i-1] = 1;
		ps[i-1] = (x+y)*(p[j]/(ll)100);
		j++;
	}
	ii ma, mi;
	if(x > y) ma = {a, x}, mi = {b, y};
	else ma = {b, y}, mi = {a, x};
	for (ll i = ma.ff; i <= n; i+=ma.ff){
		if(!v[i-1]) {
			v[i-1] = 1;
			ps[i-1] = (ma.ss)*(p[j]/(ll)100);
			j++;
		}
	}
	for (ll i = mi.ff; i <= n; i+=mi.ff){
		if(!v[i-1]) {
			v[i-1] = 1;
			ps[i-1] = (mi.ss)*(p[j]/(ll)100);
			j++;
		}
	}
	ll sum = (ll)0;
	for (ll i = 0; i < n; ++i){
		sum+=ps[i];
 	}
	return sum-k >= 0;
}

int main(){
	ll q;
	scanf("%lld", &q);

	while(q--){
		ll n, x, a, y, b, k;
		vl p;
		scanf("%lld", &n);
		for (ll i = 0; i < n; ++i){
			ll h;
			scanf("%lld", &h);
			p.pb(h);
		}
		scanf("%lld %lld %lld %lld", &x, &a, &y, &b);
		scanf("%lld", &k);
		sort(p.begin(), p.end());
		reverse(p.begin(), p.end());
		ll l = 0, r = n, ans = -1;
		while(l <= r){
			ll mid = (l+r)/2;
			if(check(a, x, b, y, k, mid, p)){
				ans = mid;
				r = mid-1;
			}else{
				l = mid+1;
			}
		}
		printf("%lld\n", ans);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+300;
int a,b,x,y,gd;
int p[N];
int gcd(int a,int b){
	if(b>a)swap(a,b);
	return b?gcd(b,a%b):a;
}
ll check(int w){
    ll ans=0;
    int kk=w/gd;
    for(int i=1;i<=kk;i++){
          ans+=1LL*p[i]*(x+y);
    }
    for(int i=kk+1;i<=w/a;i++){
         ans+=1LL*p[i]*x;
    }
    for(int i=w/a+1;i<=w/a+w/b-kk;i++){
    	ans+=1LL*p[i]*y;
    }
	return ans;
}
bool cmp(int a,int b){
	return a>b;
}
int main(){
	    int q;cin>>q;
	    while(q--){
		int n;ll k;cin>>n;
		for(int i=1;i<=n;i++)cin>>p[i],p[i]/=100;
		cin>>x>>a;
        cin>>y>>b>>k;
        if(x<y)swap(x,y),swap(a,b);
        gd=1LL*a*b/gcd(a,b);
		sort(p+1,p+1+n,cmp);
        int l=0,r=n+1;
        while(l<r){
        	int mid=(l+r)/2;
        	if(check(mid)>=k)r=mid;
        	else l=mid+1;
        }
        if(l==n+1)printf("-1\n");
        else printf("%d\n",r);
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+300;
int a,b,x,y,gd;
int p[N];
int gcd(int a,int b){
	if(b>a)swap(a,b);
	return b?gcd(b,a%b):a;
}
ll check(int w){
    ll ans=0;
    int kk=w/gd;
    for(int i=1;i<=kk&&i<=w;i++){
          ans+=1LL*p[i]*(x+y);
    }
    for(int i=kk+1;i<=w/a&&i<=w;i++){
         ans+=1LL*p[i]*x;
    }
    for(int i=w/a+1;i<=w/a+w/b-kk&&i<=w;i++){
    	ans+=1LL*p[i]*y;
    }
	return ans;
}
bool cmp(int a,int b){
	return a>b;
}
int main(){
	    int q;cin>>q;
	    while(q--){
		int n;ll k;cin>>n;
		for(int i=1;i<=n;i++)cin>>p[i],p[i]/=100;
		cin>>x>>a;
        cin>>y>>b>>k;
        if(x<y)swap(x,y),swap(a,b);
        gd=1LL*a*b/gcd(a,b);
		sort(p+1,p+1+n,cmp);
        int l=0,r=n+1;
        while(l<r){
        	int mid=(l+r)/2;
        	if(check(mid)>=k)r=mid;
        	else l=mid+1;
        }
        if(r==n+1)printf("-1\n");
        else printf("%d\n",r);
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+300;
int a,b,x,y,gd,n;
int p[N];
int gcd(int aa,int bb){
	if(bb>aa)swap(aa,bb);
	return bb?gcd(b,aa%bb):aa;
}
ll check(int w){
    ll ans=0;
    int kk=w/gd;
    for(int i=1;i<=kk;i++){
          ans+=1LL*p[i]*(x+y);
    }
    for(int i=kk+1;i<=w/a&&i<=n;i++){
         ans+=1LL*p[i]*x;
    }
    for(int i=w/a+1;i<=w/a+w/b-kk&&i<=n;i++){
    	ans+=1LL*p[i]*y;
    }
	return ans;
}
bool cmp(int a,int b){
	return a>b;
}
int main(){
	    int q;cin>>q;
	    while(q--){
		ll k;cin>>n;
		for(int i=1;i<=n;i++)cin>>p[i],p[i]/=100;
		cin>>x>>a;
        cin>>y>>b>>k;
        if(x<y)swap(x,y),swap(a,b);
        gd=1LL*a*b/gcd(a,b);
		sort(p+1,p+1+n,cmp);
        int l=0,r=n+1;
        while(l<r){
        	int mid=(l+r)/2;
        	if(check(mid)>=k)r=mid;
        	else l=mid+1;
        }
        if(l==n+1)printf("-1\n");
        else printf("%d\n",l);
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+300;
int a,b,x,y;ll gd;
int p[N];
int gcd(int a,int b){
	if(b>a)swap(a,b);
	return b?gcd(b,a%b):a;
}
ll check(int w){
    ll ans=0;
    int kk=w/gd;
    for(int i=1;i<=kk&&i<=w;i++){
          ans+=1LL*p[i]*(x+y);
    }
    for(int i=kk+1;i<=w/a&&i<=w;i++){
         ans+=1LL*p[i]*x;
    }
    for(int i=w/a+1;i<=w/a+w/b-kk&&i<=w;i++){
    	ans+=1LL*p[i]*y;
    }
	return ans;
}
bool cmp(int a,int b){
	return a>b;
}
int main(){
	    int q;cin>>q;
	    while(q--){
		int n;ll k;cin>>n;
		for(int i=1;i<=n;i++)cin>>p[i],p[i]/=100;
		cin>>x>>a;
        cin>>y>>b>>k;
        if(x<y)swap(x,y),swap(a,b);
        gd=1LL*a*b/gcd(a,b);
		sort(p+1,p+1+n,cmp);
        int l=0,r=n+1;
        while(l<r){
        	int mid=(l+r)/2;
        	if(check(mid)>=k)r=mid;
        	else l=mid+1;
        }
        if(r==n+1)printf("-1\n");
        else printf("%d\n",r);
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+300;
int a,b,x,y,gd;
int p[N];
int gcd(int a,int b){
	if(b>a)swap(a,b);
	return b?gcd(b,a%b):a;
}
ll check(int w){
    ll ans=0;
    int kk=w/gd;
    for(int i=1;i<=kk;i++){
          ans+=1LL*p[i]*(x+y);
    }
    for(int i=kk+1;i<=w/a;i++){
         ans+=1LL*p[i]*x;
    }
    for(int i=w/a+1;i<=w/a+w/b-kk;i++){
    	ans+=1LL*p[i]*y;
    }
	return ans;
}
bool cmp(int a,int b){
	return a>b;
}
int main(){
	    int q;cin>>q;
	    while(q--){
		int n;ll k;cin>>n;
		for(int i=1;i<=n;i++)cin>>p[i],p[i]/=100;
		cin>>x>>a;
        cin>>y>>b>>k;
        if(x<y)swap(x,y),swap(a,b);
        gd=1LL*a*b/gcd(a,b);
		sort(p+1,p+1+n,cmp);
        int l=0,r=n+1;
        while(l<r){
        	int mid=(l+r)/2;
        	if(check(mid)>=k)r=mid;
        	else l=mid+1;
        }
        if(l==n+1)printf("-1\n");
        else printf("%d\n",l);
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+300;
int a,b,x,y,gd;
int p[N];
int gcd(int aa,int bb){
	if(bb>aa)swap(aa,bb);
	return bb?gcd(b,aa%bb):aa;
}
ll check(int w){
    ll ans=0;
    int kk=w/gd;
    for(int i=1;i<=kk;i++){
          ans+=1LL*p[i]*(x+y);
    }
    for(int i=kk+1;i<=w/a&&i<=n;i++){
         ans+=1LL*p[i]*x;
    }
    for(int i=w/a+1;i<=w/a+w/b-kk&&i<=n;i++){
    	ans+=1LL*p[i]*y;
    }
	return ans;
}
bool cmp(int a,int b){
	return a>b;
}
int main(){
	    int q;cin>>q;
	    while(q--){
		int n;ll k;cin>>n;
		for(int i=1;i<=n;i++)cin>>p[i],p[i]/=100;
		cin>>x>>a;
        cin>>y>>b>>k;
        if(x<y)swap(x,y),swap(a,b);
        gd=1LL*a*b/gcd(a,b);
		sort(p+1,p+1+n,cmp);
        int l=0,r=n+1;
        while(l<r){
        	int mid=(l+r)/2;
        	if(check(mid)>=k)r=mid;
        	else l=mid+1;
        }
        if(l==n+1)printf("-1\n");
        else printf("%d\n",l);
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+300;
int a,b,x,y;
int p[N];
ll check(int w){
    ll ans=0;
    for(int i=1;i<=w/a;i++){
          ans+=1LL*p[i]*x;
    }
    for(int i=1;i<=w/b;i++){
         ans+=1LL*p[i]*y;
    }
	return ans;
}
bool cmp(int a,int b){
	return a>b;
}
int main(){
	    int q;cin>>q;
	    while(q--){
		int n;ll k;cin>>n;
		for(int i=1;i<=n;i++)cin>>p[i],p[i]/=100;
		cin>>x>>a;
        cin>>y>>b>>k;
		sort(p+1,p+1+n,cmp);
        int l=0,r=n+1;
        while(l<r){
        	int mid=(l+r)/2;
        	if(check(mid)>=k)r=mid;
        	else l=mid+1;
        }
        if(l==n+1)printf("-1\n");
        else printf("%d\n",l);
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, x, a, y, b;
ll k;
ll p[201010];

ll lcm(ll xx, ll yy){
	ll gcdv = __gcd(xx, yy);
	return xx / gcdv * yy;
}

int solve(ll mid){
	ll acnt = mid/a;
	ll bcnt = mid/b;
	ll ccnt = mid/ lcm(a, b);
	acnt -= ccnt;
	bcnt -= ccnt;

	ll sum = 0;
	int now = n;

	while(now > 0 && ccnt > 0){
		sum += p[now] / 100 * (x+y);
		now--;
		ccnt--;
	}
	while(now > 0 && acnt > 0){
		sum += p[now] / 100 * x;
		now--;
		acnt--;
	}
	now = n;
	while(now > 0 && bcnt > 0){
		sum += p[now] / 100 * y;
		now--;
		bcnt--;
	}
	return (sum >= k);
}
ll binary_search(ll xx, ll yy) {
	ll lo = xx - 1;
	ll hi = yy + 1;

	while (lo + 1 < hi) {
		ll mid = (lo + hi) / 2;
		if (solve(mid)) hi = mid;
		else lo = mid;
	}
	return hi;
}

int main()
{
	int q;
	scanf("%d",  &q);
	while(q--){
		scanf("%d", &n);
		for(int i=1; i<=n; i++) scanf("%lld", &p[i]);
		scanf("%d %d %d %d", &x, &a, &y, &b);
		if(x < y){
			swap(x, y);
			swap(a, b);
		}
		scanf("%lld", &k);
		sort(p+1, p+n+1);

		ll ans = binary_search(0, n);
		if(ans > n) printf("-1\n");
		else printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, x, a, y, b;
ll k;
int p[201010];

int solve(ll mid){
	ll acnt = mid/a;
	ll bcnt = mid/b;
	ll sum = 0;
	int now;

	now = n;
	while(now > 0 && acnt > 0){
		sum += p[now] / 100 * x;
		now--;
		acnt--;
	}
	now = n;
	while(now > 0 && bcnt > 0){
		sum += p[now] / 100 * y;
		now--;
		bcnt--;
	}
	return (sum >= k);
}
ll binary_search(ll xx, ll yy) {
	ll lo = xx - 1;
	ll hi = yy + 1;

	while (lo + 1 < hi) {
		ll mid = (lo + hi) / 2;
		if (solve(mid)) hi = mid;
		else lo = mid;
	}
	return hi;
}

int main()
{
	int q;
	scanf("%d",  &q);
	while(q--){
		scanf("%d", &n);
		for(int i=1; i<=n; i++) scanf("%d", &p[i]);
		scanf("%d %d %d %d", &x, &a, &y, &b);
		if(x < y){
			swap(x, y);
			swap(a, b);
		}
		scanf("%lld", &k);
		sort(p+1, p+n+1);

		ll ans = binary_search(0, (ll)1e14);
		if(ans > 1e14) printf("-1\n");
		else printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, x, a, y, b;
ll k;
ll p[201010];

ll lcm(ll xx, ll yy){
	ll gcdv = __gcd(xx, yy);
	return xx / gcdv * yy;
}

int solve(ll mid){
	ll acnt = mid/a;
	ll bcnt = mid/b;
	ll ccnt = mid/ lcm(a, b);
	acnt -= ccnt;
	bcnt -= ccnt;

	ll sum = 0;
	int now = n;

	while(now > 0 && ccnt > 0){
		sum += p[now] / 100 * (x+y);
		now--;
		ccnt--;
	}
	while(now > 0 && acnt > 0){
		sum += p[now] / 100 * x;
		now--;
		acnt--;
	}
	while(now > 0 && bcnt > 0){
		sum += p[now] / 100 * y;
		now--;
		bcnt--;
	}
	return (sum >= k);
}
ll binary_search(ll xx, ll yy) {
	ll lo = xx - 1;
	ll hi = yy + 1;

	while (lo + 1 < hi) {
		ll mid = (lo + hi) / 2;
		if (solve(mid)) hi = mid;
		else lo = mid;
	}
	return hi;
}

int main()
{
	int q;
	scanf("%d",  &q);
	while(q--){
		scanf("%d", &n);
		for(int i=1; i<=n; i++) scanf("%lld", &p[i]);
		scanf("%d %d %d %d", &x, &a, &y, &b);
		if(x < y){
			swap(x, y);
			swap(a, b);
		}
		scanf("%lld", &k);
		sort(p+1, p+n+1);

		ll ans = binary_search(0, n);
		if(ans > n) printf("-1\n");
		else printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, x, a, y, b;
ll k;
ll p[201010];

int solve(ll mid){
	ll acnt = mid/a;
	ll bcnt = mid/b;
	ll sum = 0;
	int now;

	now = n;
	while(now > 0 && acnt > 0){
		sum += p[now] / 100 * x;
		now--;
		acnt--;
	}
	now = n;
	while(now > 0 && bcnt > 0){
		sum += p[now] / 100 * y;
		now--;
		bcnt--;
	}
	return (sum >= k);
}
ll binary_search(ll xx, ll yy) {
	ll lo = xx - 1;
	ll hi = yy + 1;

	while (lo + 1 < hi) {
		ll mid = (lo + hi) / 2;
		if (solve(mid)) hi = mid;
		else lo = mid;
	}
	return hi;
}

int main()
{
	int q;
	scanf("%d",  &q);
	while(q--){
		scanf("%d", &n);
		for(int i=1; i<=n; i++) scanf("%lld", &p[i]);
		scanf("%d %d %d %d", &x, &a, &y, &b);
		if(x < y){
			swap(x, y);
			swap(a, b);
		}
		scanf("%lld", &k);
		sort(p+1, p+n+1);

		ll ans = binary_search(0, n);
		if(ans > n) printf("-1\n");
		else printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, x, a, y, b;
ll k;
int p[201010];

int solve(ll mid){
	ll acnt = mid/a;
	ll bcnt = mid/b;
	ll sum = 0;
	int now;

	now = n;
	while(now > 0 && acnt > 0){
		sum += p[now] / 100 * x;
		now--;
		acnt--;
	}
	now = n;
	while(now > 0 && bcnt > 0){
		sum += p[now] / 100 * y;
		now--;
		bcnt--;
	}
	return (sum >= k);
}
ll binary_search(ll xx, ll yy) {
	ll lo = xx - 1;
	ll hi = yy + 1;

	while (lo + 1 < hi) {
		ll mid = (lo + hi) / 2;
		if (solve(mid)) hi = mid;
		else lo = mid;
	}
	return hi;
}

int main()
{
	int q;
	scanf("%d",  &q);
	while(q--){
		scanf("%d", &n);
		for(int i=1; i<=n; i++) scanf("%d", &p[i]);
		scanf("%d %d %d %d", &x, &a, &y, &b);
		if(x < y){
			swap(x, y);
			swap(a, b);
		}
		scanf("%lld", &k);
		sort(p+1, p+n+1);

		ll ans = binary_search(0, n);
		if(ans > n) printf("-1\n");
		else printf("%lld\n", ans);
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
// #include <bits/stdc++.h>
#define ll long long
// #define MOD
using namespace std;

int lcm(int x, int y, int n){
	for (int i = 1; i < n; ++i)
	{
		if (i%x == 0 && i % y == 0)
			return i;
	}
	return -1;
}

int main(){
	int t;
	cin>>t;
	for (int num_tests = 0; num_tests < t; ++num_tests)
	{
		int n;
		cin>>n;
		vector<ll> p;
		p.clear();
		for (int i = 0; i < n; ++i)
		{
			ll tmp;
			cin>>tmp;
			p.push_back(tmp);
		}
		int x,a;
		cin>>x>>a;
		int y,b;
		cin>>y>>b;
		ll k;
		cin>>k;
		sort(p.begin(), p.end(),greater<ll>());
		for (int i = 1; i < n; ++i)
		{
			p[i] += p[i-1];
		}
		int l = lcm(a,b,n);
		// cout<<a<<" "<<b<<" "<<l<<endl;
		bool flag = false;
		for (int i = 1; i <= n; i++){
			int numboth;
			if (l != -1)
				numboth = (i/l);
			else{
				numboth = 0;
			}
			int numx = (i/a) - numboth;
			int numy = (i/b) - numboth;
			int numtot = numx + numy + numboth;
			// cout<<numboth<<" "<<numx<<" "<<numy<<" "<<numtot<<endl;
			ll tot = 0;
			if (x > y){
				ll sumx = 0,sumy = 0,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numx > 0)
					sumx = p[numboth + numx - 1] - sumboth;
				if (numy > 0)
					sumy = p[numboth + numx + numy - 1] - sumx - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			else{
				ll sumx = 0,sumy = 0,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numy > 0)
					sumy = p[numboth + numy - 1] - sumboth;
				if (numx > 0)
					sumx = p[numboth + numx + numy - 1] - sumy - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			cout<<tot<<endl;
			if (tot >= k){
				cout<<i<<endl;
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			cout<<-1<<endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
// #include <bits/stdc++.h>
#define ll long long
// #define MOD
using namespace std;

int lcm(int x, int y, int n){
	for (int i = 1; i < n; ++i)
	{
		if (i%x == 0 && i % y == 0)
			return i;
	}
	return -1;
}

int main(){
	int t;
	cin>>t;
	for (int num_tests = 0; num_tests < t; ++num_tests)
	{
		int n;
		cin>>n;
		vector<ll> p;
		p.clear();
		for (int i = 0; i < n; ++i)
		{
			ll tmp;
			cin>>tmp;
			p.push_back(tmp);
		}
		int x,a;
		cin>>x>>a;
		int y,b;
		cin>>y>>b;
		ll k;
		cin>>k;
		sort(p.begin(), p.end(),greater<ll>());
		for (int i = 1; i < n; ++i)
		{
			p[i] += p[i-1];
		}
		int l = lcm(a,b,n);
		// cout<<a<<" "<<b<<" "<<l<<endl;
		bool flag = false;
		for (int i = 1; i <= n; i++){
			int numboth;
			if (l != -1)
				numboth = (i/l);
			else{
				numboth = 0;
			}
			int numx = (i/a) - numboth;
			int numy = (i/b) - numboth;
			int numtot = numx + numy + numboth;
			// cout<<numboth<<" "<<numx<<" "<<numy<<" "<<numtot<<endl;
			ll tot = 0;
			if (x > y){
				ll sumx = 0,sumy = 0,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numx > 0)
					sumx = p[numboth + numx - 1] - sumboth;
				if (numy > 0)
					sumy = p[numboth + numx + numy - 1] - sumx - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			else{
				ll sumx = 0,sumy = 0,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numy > 0)
					sumy = p[numboth + numy - 1] - sumboth;
				if (numx > 0)
					sumx = p[numboth + numx + numy - 1] - sumy - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			// cout<<tot<<endl;
			if (tot >= k){
				cout<<i<<endl;
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			cout<<-1<<endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
// #include <bits/stdc++.h>
#define ll long long
// #define MOD
using namespace std;

int lcm(int x, int y, int n){
	for (int i = 1; i < n; ++i)
	{
		if (i%x == 0 && i % y == 0)
			return i;
	}
	return -1;
}

int main(){
	int t;
	cin>>t;
	for (int num_tests = 0; num_tests < t; ++num_tests)
	{
		int n;
		cin>>n;
		vector<ll> p;
		p.clear();
		for (int i = 0; i < n; ++i)
		{
			ll tmp;
			cin>>tmp;
			p.push_back(tmp);
		}
		ll x;
		ll a;
		cin>>x>>a;
		ll y;
		ll b;
		cin>>y>>b;
		ll k;
		cin>>k;
		sort(p.begin(), p.end(),greater<ll>());
		for (int i = 1; i < n; ++i)
		{
			p[i] += p[i-1];
		}
		int l = lcm(a,b,n);
		// cout<<a<<" "<<b<<" "<<l<<endl;
		bool flag = false;
		for (int i = 1; i <= n; i++){
			int numboth;
			if (l != -1)
				numboth = (i/l);
			else{
				numboth = 0;
			}
			int numx = (i/a) - numboth;
			int numy = (i/b) - numboth;
			int numtot = numx + numy + numboth;
			cout<<numboth<<" "<<numx<<" "<<numy<<" "<<numtot<<endl;
			ll tot = 0;
			if (x > y){
				ll sumx = 0;
				ll sumy = 0;
				ll sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numx > 0)
					sumx = p[numboth + numx - 1] - sumboth;
				if (numy > 0)
					sumy = p[numboth + numx + numy - 1] - sumx - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			else{
				ll sumx = 0;
				ll sumy = 0;
				ll sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numy > 0)
					sumy = p[numboth + numy - 1] - sumboth;
				if (numx > 0)
					sumx = p[numboth + numx + numy - 1] - sumy - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			cout<<tot<<endl;
			if (tot >= k){
				cout<<i<<endl;
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			cout<<-1<<endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
// #include <bits/stdc++.h>
#define ll long long
// #define MOD
using namespace std;

int lcm(int x, int y, int n){
	if (x == 1) return y;
	if (y == 1) return x;
	for (int i = 1; i < n; ++i)
	{
		if (i%x == 0 && i % y == 0)
			return i;
	}
	return -1;
}

int main(){
	int t;
	cin>>t;
	for (int num_tests = 0; num_tests < t; ++num_tests)
	{
		int n;
		cin>>n;
		vector<ll> p;
		p.clear();
		for (int i = 0; i < n; ++i)
		{
			ll tmp;
			cin>>tmp;
			p.push_back(tmp);
		}
		ll x;
		ll a;
		cin>>x>>a;
		ll y;
		ll b;
		cin>>y>>b;
		ll k;
		cin>>k;
		sort(p.begin(), p.end(),greater<ll>());
		for (int i = 1; i < n; ++i)
		{
			p[i] += p[i-1];
		}
		int l = lcm(a,b,n);
		// cout<<a<<" "<<b<<" "<<l<<endl;
		bool flag = false;
		for (int i = 1; i <= n; i++){
			int numboth;
			if (l != -1)
				numboth = (i/l);
			else{
				numboth = 0;
			}
			int numx = (i/a) - numboth;
			int numy = (i/b) - numboth;
			int numtot = numx + numy + numboth;
			// cout<<numboth<<" "<<numx<<" "<<numy<<" "<<numtot<<endl;
			ll tot = 0;
			if (x > y){
				ll sumx = 0;
				ll sumy = 0;
				ll sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numx > 0)
					sumx = p[numboth + numx - 1] - sumboth;
				if (numy > 0)
					sumy = p[numboth + numx + numy - 1] - sumx - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			else{
				ll sumx = 0;
				ll sumy = 0;
				ll sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numy > 0)
					sumy = p[numboth + numy - 1] - sumboth;
				if (numx > 0)
					sumx = p[numboth + numx + numy - 1] - sumy - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			// cout<<tot<<endl;
			if (tot >= k){
				cout<<i<<endl;
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			cout<<-1<<endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
// #include <bits/stdc++.h>
#define ll long long
// #define MOD
using namespace std;

int lcm(int x, int y, int n){
	for (int i = 1; i < n; ++i)
	{
		if (i%x == 0 && i % y == 0)
			return i;
	}
	return -1;
}

int main(){
	int t;
	cin>>t;
	for (int num_tests = 0; num_tests < t; ++num_tests)
	{
		int n;
		cin>>n;
		vector<ll> p;
		p.clear();
		for (int i = 0; i < n; ++i)
		{
			ll tmp;
			cin>>tmp;
			p.push_back(tmp);
		}
		ll x;
		ll a;
		cin>>x>>a;
		ll y;
		ll b;
		cin>>y>>b;
		ll k;
		cin>>k;
		sort(p.begin(), p.end(),greater<ll>());
		for (int i = 1; i < n; ++i)
		{
			p[i] += p[i-1];
		}
		int l = lcm(a,b,n);
		// cout<<a<<" "<<b<<" "<<l<<endl;
		bool flag = false;
		for (int i = 1; i <= n; i++){
			int numboth;
			if (l != -1)
				numboth = (i/l);
			else{
				numboth = 0;
			}
			int numx = (i/a) - numboth;
			int numy = (i/b) - numboth;
			int numtot = numx + numy + numboth;
			// cout<<numboth<<" "<<numx<<" "<<numy<<" "<<numtot<<endl;
			ll tot = 0;
			if (x > y){
				ll sumx = 0;
				ll sumy = 0;
				ll sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numx > 0)
					sumx = p[numboth + numx - 1] - sumboth;
				if (numy > 0)
					sumy = p[numboth + numx + numy - 1] - sumx - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			else{
				ll sumx = 0;
				ll sumy = 0;
				ll sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numy > 0)
					sumy = p[numboth + numy - 1] - sumboth;
				if (numx > 0)
					sumx = p[numboth + numx + numy - 1] - sumy - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			// cout<<tot<<endl;
			if (tot >= k){
				cout<<i<<endl;
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			cout<<-1<<endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
// #include <bits/stdc++.h>
#define ll long long
// #define MOD
using namespace std;

int lcm(int x, int y, int n){
	for (int i = 1; i < n; ++i)
	{
		if (i%x == 0 && i % y == 0)
			return i;
	}
	return -1;
}

int main(){
	int t;
	cin>>t;
	for (int num_tests = 0; num_tests < t; ++num_tests)
	{
		int n;
		cin>>n;
		vector<ll> p;
		p.clear();
		for (int i = 0; i < n; ++i)
		{
			ll tmp;
			cin>>tmp;
			p.push_back(tmp);
		}
		int x,a;
		cin>>x>>a;
		int y,b;
		cin>>y>>b;
		ll k;
		cin>>k;
		sort(p.begin(), p.end(),greater<ll>());
		for (int i = 1; i < n; ++i)
		{
			p[i] += p[i-1];
		}
		int l = lcm(a,b,n);
		// cout<<a<<" "<<b<<" "<<l<<endl;
		bool flag = false;
		for (int i = 1; i <= n; i++){
			int numboth;
			if (l != -1)
				numboth = (i/l);
			else{
				numboth = 0;
			}
			int numx = (i/a) - numboth;
			int numy = (i/b) - numboth;
			int numtot = numx + numy + numboth;
			// cout<<numboth<<" "<<numx<<" "<<numy<<" "<<numtot<<endl;
			ll tot = 0;
			if (x > y){
				ll sumx = 0,sumy = 0,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numx > 0)
					sumx = p[numboth + numx - 1] - sumboth;
				if (numy > 0)
					sumy = p[numboth + numx + numy - 1] - sumx - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			else{
				ll sumx = 0,sumy = 0,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numy > 0)
					sumy = p[numboth + numy - 1] - sumboth;
				if (numx > 0)
					sumx = p[numboth + numx + numy - 1] - sumy - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			// cout<<tot<<endl;
			if (tot >= k){
				cout<<i<<endl;
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			cout<<2<<endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
// #include <bits/stdc++.h>
#define ll long long
// #define MOD
using namespace std;

int lcm(int x, int y, int n){
	for (int i = 1; i < n; ++i)
	{
		if (i%x == 0 && i % y == 0)
			return i;
	}
	return -1;
}

int main(){
	int t;
	cin>>t;
	for (int num_tests = 0; num_tests < t; ++num_tests)
	{
		int n;
		cin>>n;
		vector<ll> p;
		p.clear();
		for (int i = 0; i < n; ++i)
		{
			ll tmp;
			cin>>tmp;
			p.push_back(tmp);
		}
		int x,a;
		cin>>x>>a;
		int y,b;
		cin>>y>>b;
		ll k;
		cin>>k;
		sort(p.begin(), p.end(),greater<ll>());
		for (int i = 1; i < n; ++i)
		{
			p[i] += p[i-1];
		}
		int l = lcm(a,b,n);
		// cout<<a<<" "<<b<<" "<<l<<endl;
		bool flag = false;
		for (int i = 1; i <= n; i++){
			int numboth;
			if (l != -1)
				numboth = (i/l);
			else{
				numboth = 0;
			}
			int numx = (i/a) - numboth;
			int numy = (i/b) - numboth;
			int numtot = numx + numy + numboth;
			// cout<<numboth<<" "<<numx<<" "<<numy<<" "<<numtot<<endl;
			ll tot = 0;
			if (x > y){
				ll sumx = 0,sumy = 0,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numx > 0)
					sumx = p[numboth + numx - 1] - sumboth;
				if (numy > 0)
					sumy = p[numboth + numx + numy - 1] - sumx - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			else{
				ll sumx = 0,sumy = 0,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numy > 0)
					sumy = p[numboth + numy - 1] - sumboth;
				if (numx > 0)
					sumx = p[numboth + numx + numy - 1] - sumy - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			// cout<<tot<<endl;
			if (tot >= k){
				cout<<i<<endl;
				flag = true;
				break;
			}
		}
		if (!flag)
			cout<<"-1"<<endl;
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
// #include <bits/stdc++.h>
#define ll long long
// #define MOD
using namespace std;

int lcm(int x, int y, int n){
	for (int i = 1; i < n; ++i)
	{
		if (i%x == 0 && i % y == 0)
			return i;
	}
	return -1;
}

int main(){
	int t;
	cin>>t;
	for (int num_tests = 0; num_tests < t; ++num_tests)
	{
		int n;
		cin>>n;
		vector<ll> p;
		p.clear();
		for (int i = 0; i < n; ++i)
		{
			ll tmp;
			cin>>tmp;
			p.push_back(tmp);
		}
		int x,a;
		cin>>x>>a;
		int y,b;
		cin>>y>>b;
		ll k;
		cin>>k;
		sort(p.begin(), p.end(),greater<ll>());
		for (int i = 1; i < n; ++i)
		{
			p[i] += p[i-1];
		}
		int l = lcm(a,b,n);
		// cout<<a<<" "<<b<<" "<<l<<endl;
		bool flag = false;
		for (int i = 1; i <= n; i++){
			int numboth;
			if (l != -1)
				numboth = (i/l);
			else{
				numboth = 0;
			}
			int numx = (i/a) - numboth;
			int numy = (i/b) - numboth;
			int numtot = numx + numy + numboth;
			// cout<<numboth<<" "<<numx<<" "<<numy<<" "<<numtot<<endl;
			ll tot = 0;
			if (x > y){
				ll sumx = 0,sumy = 0,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numx > 0)
					sumx = p[numboth + numx - 1] - sumboth;
				if (numy > 0)
					sumy = p[numboth + numx + numy - 1] - sumx - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			else{
				ll sumx,sumy,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numy > 0)
					sumy = p[numboth + numy - 1] - sumboth;
				if (numx > 0)
					sumx = p[numboth + numx + numy - 1] - sumy - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			if (tot >= k){
				cout<<i<<endl;
				flag = true;
				break;
			}
		}
		if (!flag)
			cout<<-1<<endl;
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
// #include <bits/stdc++.h>
#define ll long long
// #define MOD
using namespace std;

int lcm(int x, int y, int n){
	for (int i = 1; i < n; ++i)
	{
		if (i%x == 0 && i % y == 0)
			return i;
	}
	return -1;
}

int main(){
	int t;
	cin>>t;
	for (int num_tests = 0; num_tests < t; ++num_tests)
	{
		int n;
		cin>>n;
		vector<ll> p;
		for (int i = 0; i < n; ++i)
		{
			ll tmp;
			cin>>tmp;
			p.push_back(tmp);
		}
		int x,a;
		cin>>x>>a;
		int y,b;
		cin>>y>>b;
		ll k;
		cin>>k;
		sort(p.begin(), p.end(),greater<ll>());
		for (int i = 1; i < n; ++i)
		{
			p[i] += p[i-1];
		}
		int l = lcm(a,b,n);
		// cout<<a<<" "<<b<<" "<<l<<endl;
		bool flag = false;
		for (int i = 1; i <= n; i++){
			int numboth;
			if (l != -1)
				numboth = (i/l);
			else{
				numboth = 0;
			}
			int numx = (i/a) - numboth;
			int numy = (i/b) - numboth;
			int numtot = numx + numy + numboth;
			// cout<<numboth<<" "<<numx<<" "<<numy<<" "<<numtot<<endl;
			ll tot = 0;
			if (x > y){
				ll sumx = 0,sumy = 0,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numx > 0)
					sumx = p[numboth + numx - 1] - sumboth;
				if (numy > 0)
					sumy = p[numboth + numx + numy - 1] - sumx - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			else{
				ll sumx,sumy,sumboth = 0;
				if (numboth > 0)
					sumboth = p[numboth - 1];
				if (numy > 0)
					sumy = p[numboth + numy - 1] - sumboth;
				if (numx > 0)
					sumx = p[numboth + numx + numy - 1] - sumy - sumboth;
				tot = (sumx / 100) * x + (sumy / 100) * y + (sumboth / 100) * (x + y);
			}
			if (tot >= k){
				cout<<i<<endl;
				flag = true;
				break;
			}
		}
		if (!flag)
			cout<<-1<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
const double PI = 3.14159265359;
const int N = 5e5 + 7;
const ll MOD = 1e9 + 7;

ll power(ll x, ll p, ll m = MOD) {
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % m;
        x = x * x % m;
        p >>= 1;
    }
    return ans;
}

ll n, q, x, a, y, b, k;
ll arr[N];

bool valid(ll m) {
    ll as = m / a;
    ll bs = m / b;
    ll profit = 0;
    for (int i = 0; i < n; ++i) {
        if (as)
            profit += arr[i] * (x) / 100, as--;
        if (bs)
            profit += arr[i] * (y) / 100, bs--;
    }
    return profit >= k;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    cin >> q;
    while (q--) {
        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
        }
        sort(arr, arr + n, greater<>());
        cin >> x >> a >> y >> b >> k;
        ll st = 0, en = 1e18;
        ll mid;
        while (st < en) {
            mid = st + (en - st) / 2;
            if (!valid(mid))
                st = mid + 1;
            else
                en = mid;
        }
        if (!valid(st)) cout << -1 << endl;
        else cout << st << endl;
    }

}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
const double PI = 3.14159265359;
const int N = 5e5 + 7;
const ll MOD = 1e9 + 7;

ll power(ll x, ll p, ll m = MOD) {
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % m;
        x = x * x % m;
        p >>= 1;
    }
    return ans;
}

ll n, q, x, a, y, b, k;
ll arr[N];

bool valid(ll m) {
    ll as = m / a;
    ll bs = m / b;
    ll profit = 0;
    for (int i = 0; i < m; ++i) {
        if (as)
            profit += arr[i] * (x) / 100, as--;
        if (bs)
            profit += arr[i] * (y) / 100, bs--;
    }
    return profit >= k;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    cin >> q;
    while (q--) {
        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
        }
        sort(arr, arr + n, greater<>());
        cin >> x >> a >> y >> b >> k;
        ll st = 0, en = n;
        ll mid;
        while (st < en) {
            mid = st + (en - st) / 2;
            if (!valid(mid))
                st = mid + 1;
            else
                en = mid;
        }
        if (!valid(st)) cout << -1 << endl;
        else cout << st << endl;
    }

}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
const double PI = 3.14159265359;
const int N = 5e5 + 7;
const ll MOD = 1e9 + 7;

ll power(ll x, ll p, ll m = MOD) {
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % m;
        x = x * x % m;
        p >>= 1;
    }
    return ans;
}

ll n, q, x, a, y, b, k;
ll arr[N];

bool valid(ll m) {
    ll cs = m / (a * b / __gcd(a, b));
    ll as = m / a - cs;
    ll bs = m / b - cs;

    ll profit = 0;
    for (int i = 0; i < m; ++i) {
        if (cs)
            profit += arr[i] * (x + y) / 100, cs--;
        else if (as)
            profit += arr[i] * (x) / 100, as--;
        else if (bs)
            profit += arr[i] * (y) / 100, bs--;
    }
    return profit >= k;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    cin >> q;
    while (q--) {
        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
        }
        sort(arr, arr + n, greater<>());
        cin >> x >> a >> y >> b >> k;
        if (y > x)
            swap(x, y), swap(a, b);
        ll st = 0, en = n;
        ll mid;
        while (st < en) {
            mid = st + (en - st) / 2;
            if (!valid(mid))
                st = mid + 1;
            else
                en = mid;
        }
        valid(3);
        if (!valid(st)) cout << -1 << endl;
        else cout << st << endl;
    }

}


#include <bits/stdc++.h>

using namespace std;

long long a, b, c;
long long k;
multiset<long long, greater<>> s2;
map<long long, long long> mp;

bool valid(long long x) {
    auto it2 = s2.begin();
    long long sum = 0;
    long long ap = mp[a], bp = mp[b], cp = mp[c];
    for (long long i = cp; i <= x; i += cp) {
        if (it2 == s2.end()) break;
        sum += 1LL * c * (*it2) / 100;
        it2++;
    }
    for (long long i = ap; i <= x; i += ap) {
        if (i % cp == 0) continue;
        if (it2 == s2.end()) break;
        sum += 1LL * a * (*it2) / 100;
        it2++;
    }
    for (long long i = bp; i <= x; i += bp) {
        if (i % cp == 0) continue;
        if (it2 == s2.end()) break;
        sum += 1LL * b * (*it2) / 100;
        it2++;
    }

//    cout << "sum: " << sum << '\n';
    return sum >= k;
}

long long bs(long long st, long long en) {
    long long mid;
    while (st < en) {
        mid = st + (en - st) / 2;
        if (!valid(mid))
            st = mid + 1;
        else
            en = mid;
    }
    if (!valid(st)) return -1;
    else return st;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    long long q;
    cin >> q;
    while (q--) {
        long long n;
        cin >> n;
        for (long long i = 0; i < n; i++) {
            long long x;
            cin >> x;
            s2.insert(x);
        }
        long long ma, mb;
        cin >> a >> ma >> b >> mb;
        if (a < b) {
            swap(a, b);
            swap(ma, mb);
        }
        //1 2 3 4 5 6 7
        mp[a] = ma;
        mp[b] = mb;
        c = a + b;
        mp[c] = ma * mb / __gcd(ma, mb);
        cin >> k;
        cout << bs(1, n) << '\n';
        s2.clear();
        mp[a] = 0, mp[b] = 0, mp[c] = 0;
    }
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
const double PI = 3.14159265359;
const int N = 5e5 + 7;
const ll MOD = 1e9 + 7;

ll power(ll x, ll p, ll m = MOD) {
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % m;
        x = x * x % m;
        p >>= 1;
    }
    return ans;
}

ll n, q, x, a, y, b, k;
ll arr[N];

bool valid(ll m) {
    ll cs = m / (a * b / __gcd(a, b));
    ll as = m / a - cs;
    ll bs = m / b - cs;
    if (y > x) swap(as, bs);
    ll profit = 0;
    for (int i = 0; i < m; ++i) {
        if (cs)
            profit += arr[i] * (x + y) / 100, cs--;
        else if (as)
            profit += arr[i] * (x) / 100, as--;
        else if (bs)
            profit += arr[i] * (y) / 100, bs--;
    }
    return profit >= k;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    cin >> q;
    while (q--) {
        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
        }
        sort(arr, arr + n, greater<>());
        cin >> x >> a >> y >> b >> k;
        ll st = 0, en = n;
        ll mid;
        while (st < en) {
            mid = st + (en - st) / 2;
            if (!valid(mid))
                st = mid + 1;
            else
                en = mid;
        }
        valid(3);
        if (!valid(st)) cout << -1 << endl;
        else cout << st << endl;
    }

}


#include <bits/stdc++.h>

using namespace std;

long long a, b, c;
long long k, ma, mb, mc;
multiset<long long, greater<>> s2;

bool valid(long long x) {
    auto it2 = s2.begin();
    long long sum = 0;
    for (long long i = mc; i <= x; i += mc) {
        if (it2 == s2.end()) break;
        sum += 1LL * c * (*it2) / 100;
        it2++;
    }
    for (long long i = ma; i <= x; i += ma) {
        if (i % mc == 0) continue;
        if (it2 == s2.end()) break;
        sum += 1LL * a * (*it2) / 100;
        it2++;
    }
    for (long long i = mb; i <= x; i += mb) {
        if (i % mc == 0) continue;
        if (it2 == s2.end()) break;
        sum += 1LL * b * (*it2) / 100;
        it2++;
    }

//    cout << "sum: " << sum << '\n';
    return sum >= k;
}

long long bs(long long st, long long en) {
    long long mid;
    while (st < en) {
        mid = st + (en - st) / 2;
        if (!valid(mid))
            st = mid + 1;
        else
            en = mid;
    }
    if (!valid(st)) return -1;
    else return st;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    long long q;
    cin >> q;
    while (q--) {
        long long n;
        cin >> n;
        for (long long i = 0; i < n; i++) {
            long long x;
            cin >> x;
            s2.insert(x);
        }
        cin >> a >> ma >> b >> mb;
        if (a < b) {
            swap(a, b);
            swap(ma, mb);
        }
        //1 2 3 4 5 6 7
        c = a + b;
        mc = ma * mb / __gcd(ma, mb);
        cin >> k;
        cout << bs(1, n) << '\n';
        s2.clear();
    }
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

ll x, a, y, b;
ll k;
ll gcd(ll x, ll y){
    if (!y)
        return x;
    return gcd(y, x%y);
}

bool cando(vector<int>& p, int m){
    ll lcm = a / gcd(a, b) * b;
    ll s = 0;
    int u = 0;
    for(int i=lcm-1; i<m; i += lcm) {
        s += p[u++] * (x+y);
    }
    for(int i=b-1; i<m; i += b) if ((i+1) % a){
        s += p[u++] * y;
    }
    for(int i=a-1; i<m; i += a) if ((i+1) % b){
        s += p[u++] * x;
    }
    return s >= k;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int q;
    cin >> q;
    FOR(i, q){
        int n;
        cin >> n;
        vector<int> p(n);
        FOR(i, n) {
            cin >> p[i];
            p[i] /= 100;
        }
        sort(p.begin(), p.end(), std::greater<int>());

        cin >> x >> a >> y >> b;
        if (x>y){
            swap(a, b);
            swap(x, y);
        }
        cin >> k;

        int l = 1, r = n, sol = n+1;
        while(l <= r){
            int m = (l+r)/2;
            if (cando(p, m)){
                sol = min(sol, m);
                r = m-1;
            }
            else{
                l = m+1;
            }
        }
        if (sol == n+1)
            cout << - 1 << endl;
        else
            cout << sol << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int x, a, y, b;
ll k;
int gcd(int x, int y){
    if (!y)
        return x;
    return gcd(y, x%y);
}

bool cando(vector<int>& p, int m){
    int lcm = a / gcd(a, b) * b;
    ll s = 0;
    vector<bool> done(m);
    int u = 0;
    for(int i=lcm-1; i<m; i+= lcm) {
        s += p[u++] * (x+y);
        done[i] = 1;
    }
    for(int i=b-1; i<m; i += b) if (i % a){
        s += p[u++] * y;
        done[i];
    }
    for(int i=a-1; i<m; i += a) if (i % b){
        s += p[u++] * x;
        done[i];
    }
    return s >= k;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int q;
    cin >> q;
    FOR(i, q){
        int n;
        cin >> n;
        vector<int> p(n);
        FOR(i, n) {
            cin >> p[i];
            p[i] /= 100;
        }
        sort(p.begin(), p.end(), std::greater<int>());

        cin >> x >> a >> y >> b;
        if (x>y){
            swap(a, b);
            swap(x, y);
        }
        cin >> k;

        int l = 1, r = n, sol = -1;
        while(l <= r){
            int m = (l+r)/2;
            if (cando(p, m)){
                sol = m;
                r = m-1;
            }
            else{
                l = m+1;
            }
        }
        cout << sol << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

ll x, a, y, b;
ll k;
ll gcd(ll x, ll y){
    if (!y)
        return x;
    return gcd(y, x%y);
}

bool cando(vector<ll>& p, int m){
    ll lcm = a / gcd(a, b) * b;
    ll s = 0;
    int u = 1;
    for(ll i=lcm; i<=m; i += lcm) {
        s += p[u] * (x+y);
        u++;
    }
    for(ll i=b; i<=m; i += b) if (i % a){
            s += p[u] * y;
            u++;
        }
    for(ll i=a; i<=m; i += a) if (i % b){
            s += p[u] * x;
            u++;
        }
    return s >= k;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int q;
    cin >> q;
    FOR(i, q){
        int n;
        cin >> n;
        vector<ll> p(n+1);
        FOR1(i, n) {
            cin >> p[i];
            p[i] /= 100;
        }
        sort(p.begin()+1, p.end(), std::greater<ll>());

        cin >> x >> a >> y >> b;
        if (x>y){
            swap(a, b);
            swap(x, y);
        }
        cin >> k;

        int l = 1, r = n, sol = n+1;
        while(l <= r){
            int m = (l+r)/2;
            if (cando(p, m)){
                sol = min(sol, m);
                r = m-1;
            }
            else{
                l = m+1;
            }
        }
        if (sol == n+1)
            cout << - 1 << endl;
        else
            cout << sol << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

ll x, a, y, b;
ll k;
ll gcd(ll x, ll y){
    if (!y)
        return x;
    return gcd(y, x%y);
}

bool cando(vector<ll>& p, int m){
    ll lcm = a / gcd(a, b) * b;
    ll s = 0;
    int u = 0;
    for(int i=lcm-1; i<m; i += lcm) {
        s += p[u] * (x+y);
        u++;
    }
    for(int i=b-1; i<m; i += b) if ((i+1) % a){
            s += p[u] * y;
            u++;
        }
    for(int i=a-1; i<m; i += a) if ((i+1) % b){
            s += p[u] * x;
            u++;
        }
    return s >= k;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int q;
    cin >> q;
    FOR(i, q){
        int n;
        cin >> n;
        vector<ll> p(n);
        FOR(i, n) {
            cin >> p[i];
            p[i] /= 100;
        }
        sort(p.begin(), p.end(), std::greater<ll>());

        cin >> x >> a >> y >> b;
        if (x>y){
            swap(a, b);
            swap(x, y);
        }
        cin >> k;

        int l = 1, r = n, sol = n+1;
        while(l <= r){
            int m = (l+r)/2;
            if (cando(p, m)){
                sol = min(sol, m);
                r = m-1;
            }
            else{
                l = m+1;
            }
        }
        if (sol == n+1)
            cout << - 1 << endl;
        else
            cout << sol << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

ll x, a, y, b;
ll k;
int gcd(int x, int y){
    if (!y)
        return x;
    return gcd(y, x%y);
}

bool cando(vector<int>& p, int m){
    int lcm = a / gcd(a, b) * b;
    ll s = 0;
    vector<bool> done(m);
    int u = 0;
    for(int i=lcm-1; i<m; i+= lcm) {
        s += p[u++] * (x+y);
        done[i] = 1;
    }
    for(int i=b-1; i<m; i += b) if (i % a){
        s += p[u++] * y;
        done[i];
    }
    for(int i=a-1; i<m; i += a) if (i % b){
        s += p[u++] * x;
        done[i];
    }
    return s >= k;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int q;
    cin >> q;
    FOR(i, q){
        int n;
        cin >> n;
        vector<int> p(n);
        FOR(i, n) {
            cin >> p[i];
            p[i] /= 100;
        }
        sort(p.begin(), p.end(), std::greater<int>());

        cin >> x >> a >> y >> b;
        if (x>y){
            swap(a, b);
            swap(x, y);
        }
        cin >> k;

        int l = 1, r = n, sol = n+1;
        while(l <= r){
            int m = (l+r)/2;
            if (cando(p, m)){
                sol = min(sol, m);
                r = m-1;
            }
            else{
                l = m+1;
            }
        }
        if (sol == n+1)
            cout << - 1 << endl;
        else
            cout << sol << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

ll x, a, y, b;
ll k;
ll gcd(ll x, ll y){
    if (!y)
        return x;
    return gcd(y, x%y);
}

bool cando(vector<ll>& p, int m){
    ll lcm = a / gcd(a, b) * b;
    ll s = 0;
    int u = 0;
    for(int i=lcm-1; i<m; i += lcm) {
        s += p[u++] * (x+y);
    }
    for(int i=b-1; i<m; i += b) if ((i+1) % a){
            s += p[u++] * y;
        }
    for(int i=a-1; i<m; i += a) if ((i+1) % b){
            s += p[u++] * x;
        }
    return s >= k;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int q;
    cin >> q;
    FOR(i, q){
        int n;
        cin >> n;
        vector<ll> p(n);
        FOR(i, n) {
            cin >> p[i];
            p[i] /= 100;
        }
        sort(p.begin(), p.end(), std::greater<ll>());

        cin >> x >> a >> y >> b;
        if (x>y){
            swap(a, b);
            swap(x, y);
        }
        cin >> k;

        int l = 1, r = n, sol = n+1;
        while(l <= r){
            int m = (l+r)/2;
            if (cando(p, m)){
                sol = min(sol, m);
                r = m-1;
            }
            else{
                l = m+1;
            }
        }
        if (sol == n+1)
            cout << - 1 << endl;
        else
            cout << sol << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

ll x, a, y, b;
ll k;
int gcd(ll x, ll y){
    if (!y)
        return x;
    return gcd(y, x%y);
}

bool cando(vector<int>& p, int m){
    ll lcm = a / gcd(a, b) * b;
    ll s = 0;
    int u = 0;
    for(int i=lcm-1; i<m; i += lcm) {
        s += p[u++] * (x+y);
    }
    for(int i=b-1; i<m; i += b) if ((i+1) % a){
        s += p[u++] * y;
    }
    for(int i=a-1; i<m; i += a) if ((i+1) % b){
        s += p[u++] * x;
    }
    return s >= k;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int q;
    cin >> q;
    FOR(i, q){
        int n;
        cin >> n;
        vector<int> p(n);
        FOR(i, n) {
            cin >> p[i];
            p[i] /= 100;
        }
        sort(p.begin(), p.end(), std::greater<int>());

        cin >> x >> a >> y >> b;
        if (x>y){
            swap(a, b);
            swap(x, y);
        }
        cin >> k;

        int l = 1, r = n, sol = n+1;
        while(l <= r){
            int m = (l+r)/2;
            if (cando(p, m)){
                sol = min(sol, m);
                r = m-1;
            }
            else{
                l = m+1;
            }
        }
        if (sol == n+1)
            cout << - 1 << endl;
        else
            cout << sol << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

ll x, a, y, b;
ll k;
ll gcd(ll x, ll y){
    if (!y)
        return x;
    return gcd(y, x%y);
}

bool cando(vector<ll>& p, int m){
    ll lcm = a / gcd(a, b) * b;
    ll s = 0;
    int u = 1;
    for(int i=lcm; i<=m; i += lcm) {
        s += p[u] * (x+y);
        u++;
    }
    for(int i=b; i<=m; i += b) if (i % a){
            s += p[u] * y;
            u++;
        }
    for(int i=a; i<=m; i += a) if (i % b){
            s += p[u] * x;
            u++;
        }
    return s >= k;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int q;
    cin >> q;
    FOR(i, q){
        int n;
        cin >> n;
        vector<ll> p(n+1);
        FOR1(i, n) {
            cin >> p[i];
            p[i] /= 100;
        }
        sort(p.begin()+1, p.end(), std::greater<ll>());

        cin >> x >> a >> y >> b;
        if (x>y){
            swap(a, b);
            swap(x, y);
        }
        cin >> k;

        int l = 1, r = n, sol = n+1;
        while(l <= r){
            int m = (l+r)/2;
            if (cando(p, m)){
                sol = min(sol, m);
                r = m-1;
            }
            else{
                l = m+1;
            }
        }
        if (sol == n+1)
            cout << - 1 << endl;
        else
            cout << sol << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

ll x, a, y, b;
ll k;
ll gcd(ll x, ll y){
    if (!y)
        return x;
    return gcd(y, x%y);
}

bool cando(vector<ll>& p, int m){
    ll lcm = a / gcd(a, b) * b;
    ll s = 0;
    int i1 = m/lcm;
    s += (x+y)*p[i1];
    int i2 = m/b - m/lcm;
    s += y*(p[i1+i2]-p[i1]);
    i2 += i1;
    int i3 = m/a - m/lcm;
    s += x*(p[i2+i3]-p[i2]);
    return s >= k;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int q;
    cin >> q;
    FOR(i, q){
        int n;
        cin >> n;
        vector<ll> p(n+1);
        FOR1(i, n) {
            cin >> p[i];
            p[i] /= 100;
        }
        sort(p.begin()+1, p.end(), std::greater<ll>());
        FOR1(i, n)
            p[i] += p[i-1];

        cin >> x >> a >> y >> b;
        if (x>y){
            swap(a, b);
            swap(x, y);
        }
        cin >> k;

        int l = 1, r = n, sol = n+1;
        while(l <= r){
            int m = (l+r)/2;
            if (cando(p, m)){
                sol = min(sol, m);
                r = m-1;
            }
            else{
                l = m+1;
            }
        }
        if (sol == n+1)
            cout << - 1 << endl;
        else
            cout << sol << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
long long ticket[maxn],arr[maxn],id[maxn];
int x,a,y,b;
bool cmp(int x,int y)
{
    return ticket[x]>ticket[y];
}
long long check(int r)
{
    long long sum=0;
    int cnt1=r/(a*b);//([1,r]经过cnt1个(lcm(a,b))的点)
    int cnt2=r/b;//defalut x<y
    int cnt3=r/a;
    if(a==b)   {cnt1=r/a;cnt2=cnt3=0;}//间隔相同时两种program指向同一点 不相同添加 将cnt1置0会出错 因为x,y值不同
    for(int i=1;i<=cnt1;i++){
        sum+=ticket[id[i]]*(x+y);//其实sort一遍ticket相同实现
    }
    for(int i=cnt1+1;i<=cnt1+cnt2;i++){
        sum+=ticket[id[i]]*y;
    }
    for(int i=cnt1+cnt2+1;i<=cnt1+cnt2+cnt3;i++){
        sum+=ticket[id[i]]*x;
    }
    return sum;
}
int main()
{
    int q;
    cin>>q;
    while(q--){
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>ticket[i];
            id[i]=i;
        }
        cin>>x>>a>>y>>b;
        //default x<y
        if(x>y){//swap
            int t=x;
            x=y;
            y=t;
            t=a;
            a=b;
            b=t;
        }
        long long k;
        cin>>k;
        k*=100;//percentage k<=1e14 k*100<=1e16 long long 1e19
        sort(id+1,id+1+n,cmp);//ticket[id[i]]==面值第i大的电影票的面值
        int l=0,r=n,ans=maxn,flag=0;
        while(l<=r){
            int mid=(l+r)>>1;
            long long ret=check(mid);
            if(ret>=k){//合法
                r=mid-1;
                flag=1;
                ans=min(ans,mid);
            }
            else l=mid+1;
        }
        if(flag)    cout<<ans<<endl;
        else cout<<-1<<endl;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<string.h>

using namespace std;
const int maxn=2e5+10;
long long ticket[maxn],arr[maxn],id[maxn];
long long x,a,y,b;
bool cmp(long long x,long long y)
{
    return x>y;
}
long long check(int r)
{
    long long sum=0;

    int cnt1=r/(a*b);//([1,r]经过cnt1个(lcm(a,b))的点)
    int cnt2=r/b;   //defalut x<y
    int cnt3=r/a;

    if(cnt2*b>=cnt1*a*b){//x+y,y
        cnt2-=cnt1;
    }
    else{//y,x+y
        cnt2=cnt2-(cnt1-1);
    }
    if(cnt3*a>=cnt1*a*b){//x+y,x
        cnt3-=cnt1;
    }
    else{//x,x+y
        cnt3=cnt3-(cnt1-1);
    }

    if(a==b)   {cnt1=r/a;cnt2=cnt3=0;}//间隔相同时两种program指向同一点 不相同添加 将cnt1置0会出错 因为x,y值不同

    for(int i=1;i<=cnt1;i++){//x+y位置
        sum+=ticket[i]*(x+y);//其实sort一遍ticket相同实现
    }
    for(int i=cnt1+1;i<=cnt1+cnt2;i++){//单独的y位置
        sum+=ticket[i]*y;
    }
    for(int i=cnt1+cnt2+1;i<=cnt1+cnt2+cnt3;i++){//单独的x位置
        sum+=ticket[i]*x;
    }
    return sum;
}
int main()
{
    int q;
    cin>>q;
    while(q--){
        memset(ticket,0,sizeof(ticket));
        memset(arr,0,sizeof(arr));
        memset(id,0,sizeof(id));
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>ticket[i];
        }
        cin>>x>>a>>y>>b;
        sort(ticket+1,ticket+1+n,cmp);//decreasing

        long long k;
        cin>>k;
        k*=100;//percentage k<=1e14 k*100<=1e16 long long 1e19
        int l=1,r=n,ans=maxn,flag=0;
        while(l<=r){
            int mid=(l+r)>>1;
            long long ret=check(mid);
            if(ret>=k){//合法
                r=mid-1;
                flag=1;
                ans=min(ans,mid);
            }
            else l=mid+1;
        }
        if(flag)    cout<<ans<<endl;
        else cout<<-1<<endl;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
long long ticket[maxn],arr[maxn],id[maxn];
int x,a,y,b;
bool cmp(int x,int y)
{
    return ticket[x]>ticket[y];
}
long long check(int r)
{
    long long sum=0;
    int cnt1=r/(a*b);//([1,r]经过cnt1个(lcm(a,b))的点)
    int cnt2=r/b;//defalut x<y
    int cnt3=r/a;
    if(a==b)    cnt2=cnt3=0;//间隔相同时两种program指向同一点 不相同添加 将cnt1置0会出错 因为x,y值不同
    for(int i=1;i<=cnt1;i++){
        sum+=ticket[id[i]]*(x+y);//其实sort一遍ticket相同实现
    }
    for(int i=cnt1+1;i<=cnt1+cnt2;i++){
        sum+=ticket[id[i]]*y;
    }
    for(int i=cnt1+cnt2+1;i<=cnt1+cnt2+cnt3;i++){
        sum+=ticket[id[i]]*x;
    }
    return sum;
}
int main()
{
    int q;
    cin>>q;
    while(q--){
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>ticket[i];
            id[i]=i;
        }
        cin>>x>>a>>y>>b;
        //default x<y
        if(x>y){//swap
            int t=x;
            x=y;
            y=t;
            t=a;
            a=b;
            b=t;
        }
        long long k;
        cin>>k;
        k*=100;//percentage k<=1e14 k*100<=1e16 long long 1e19
        sort(id+1,id+1+n,cmp);//ticket[id[i]]==面值第i大的电影票的面值
        int l=0,r=n,ans=maxn,flag=0;
        while(l<=r){
            int mid=(l+r)>>1;
            long long ret=check(mid);
            if(ret>=k){//合法
                r=mid-1;
                flag=1;
                ans=min(ans,mid);
            }
            else l=mid+1;
        }
        if(flag)    cout<<ans<<endl;
        else cout<<-1<<endl;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
long long ticket[maxn],arr[maxn],id[maxn];
int x,a,y,b;
bool cmp(int x,int y)
{
    return ticket[x]>ticket[y];
}
long long check(int r)
{
    long long sum=0;
    int cnt1=r/(a*b);//([1,r]经过cnt1个(lcm(a,b))的点)
    int cnt2=r/b;//defalut x<y
    int cnt3=r/a;

    if(cnt2*b>=cnt1*a*b){//x+y,y
        cnt2-=cnt1;
    }
    else{//y,x+y
        cnt2=cnt2-cnt1+1;//减多了1加回
    }
    if(cnt3*a>=cnt1*a*b){
        cnt3-=cnt1;
    }
    else{//x,x+y
        cnt3=cnt3-cnt1+1;
    }

    if(a==b)   {cnt1=r/a;cnt2=cnt3=0;}//间隔相同时两种program指向同一点 不相同添加 将cnt1置0会出错 因为x,y值不同
    for(int i=1;i<=cnt1;i++){
        sum+=ticket[id[i]]*(x+y);//其实sort一遍ticket相同实现
    }
    for(int i=cnt1+1;i<=cnt1+cnt2;i++){
        sum+=ticket[id[i]]*y;
    }
    for(int i=cnt1+cnt2+1;i<=cnt1+cnt2+cnt3;i++){
        sum+=ticket[id[i]]*x;
    }
    return sum;
}
int main()
{
    int q;
    cin>>q;
    while(q--){
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>ticket[i];
            id[i]=i;
        }
        cin>>x>>a>>y>>b;
        //default x<y
        if(x>y){//swap
            int t=x;
            x=y;
            y=t;
            t=a;
            a=b;
            b=t;
        }
        long long k;
        cin>>k;
        k*=100;//percentage k<=1e14 k*100<=1e16 long long 1e19
        sort(id+1,id+1+n,cmp);//ticket[id[i]]==面值第i大的电影票的面值
        int l=0,r=n,ans=maxn,flag=0;
        while(l<=r){
            int mid=(l+r)>>1;
            long long ret=check(mid);
            if(ret>=k){//合法
                r=mid-1;
                flag=1;
                ans=min(ans,mid);
            }
            else l=mid+1;
        }
        if(flag)    cout<<ans<<endl;
        else cout<<-1<<endl;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<string.h>

using namespace std;
const int maxn=2e5+10;
long long ticket[maxn],arr[maxn],id[maxn];
long long x,a,y,b;
bool cmp(int x,int y)
{
    return ticket[x]>ticket[y];
}
long long check(int r)
{
    long long sum=0;

    int cnt1=r/(a*b);//([1,r]经过cnt1个(lcm(a,b))的点)
    int cnt2=r/b;   //defalut x<y
    int cnt3=r/a;

    if(cnt2*b>=cnt1*a*b){//x+y,y
        cnt2-=cnt1;
    }
    else{//y,x+y
        cnt2=cnt2-(cnt1-1);
    }
    if(cnt3*a>=cnt1*a*b){//x+y,x
        cnt3-=cnt1;
    }
    else{//x,x+y
        cnt3=cnt3-(cnt1-1);
    }

    if(a==b)   {cnt1=r/a;cnt2=cnt3=0;}//间隔相同时两种program指向同一点 不相同添加 将cnt1置0会出错 因为x,y值不同

    for(int i=1;i<=cnt1;i++){//x+y位置
        sum+=ticket[id[i]]*(x+y);//其实sort一遍ticket相同实现
    }
    for(int i=cnt1+1;i<=cnt1+cnt2;i++){//单独的y位置
        sum+=ticket[id[i]]*y;
    }
    for(int i=cnt1+cnt2+1;i<=cnt1+cnt2+cnt3;i++){//单独的x位置
        sum+=ticket[id[i]]*x;
    }
    return sum;
}
int main()
{
    int q;
    cin>>q;
    while(q--){
        memset(ticket,0,sizeof(ticket));
        memset(arr,0,sizeof(arr));
        memset(id,0,sizeof(id));
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>ticket[i];
            id[i]=i;
        }
        cin>>x>>a>>y>>b;

        //default x<y

//        if(x>y){//swap
//            long long t=x;
//            x=y;
//            y=t;
//            t=a;
//            a=b;
//            b=t;
//        }
        long long k;
        cin>>k;
        k*=100;//percentage k<=1e14 k*100<=1e16 long long 1e19

        sort(id+1,id+1+n,cmp);//ticket[id[i]]==面值第i大的电影票的面值

        int l=1,r=n,ans=maxn,flag=0;
        while(l<=r){
            int mid=(l+r)>>1;
            long long ret=check(mid);
            if(ret>=k){//合法
                r=mid-1;
                flag=1;
                ans=min(ans,mid);
            }
            else l=mid+1;
        }
        if(flag)    cout<<ans<<endl;
        else cout<<-1<<endl;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<string.h>

using namespace std;
const int maxn=2e5+10;
long long ticket[maxn],arr[maxn],id[maxn];
long long x,a,y,b;
bool cmp(int x,int y)
{
    return ticket[x]>ticket[y];
}
long long check(int r)
{
    long long sum=0;

    int cnt1=r/(a*b);//([1,r]经过cnt1个(lcm(a,b))的点)
    int cnt2=r/b;   //defalut x<y
    int cnt3=r/a;

    if(cnt2*b>=cnt1*a*b){//x+y,y
        cnt2-=cnt1;
    }
    else{//y,x+y
        cnt2=cnt2-(cnt1-1);
    }
    if(cnt3*a>=cnt1*a*b){//x+y,x
        cnt3-=cnt1;
    }
    else{//x,x+y
        cnt3=cnt3-(cnt1-1);
    }

    if(a==b)   {cnt1=r/a;cnt2=cnt3=0;}//间隔相同时两种program指向同一点 不相同添加 将cnt1置0会出错 因为x,y值不同

    for(int i=1;i<=cnt1;i++){//x+y位置
        sum+=ticket[id[i]]*(x+y);//其实sort一遍ticket相同实现
    }
    for(int i=cnt1+1;i<=cnt1+cnt2;i++){//单独的y位置
        sum+=ticket[id[i]]*y;
    }
    for(int i=cnt1+cnt2+1;i<=cnt1+cnt2+cnt3;i++){//单独的x位置
        sum+=ticket[id[i]]*x;
    }
    return sum;
}
int main()
{
    int q;
    cin>>q;
    while(q--){
        memset(ticket,0,sizeof(ticket));
        memset(arr,0,sizeof(arr));
        memset(id,0,sizeof(id));
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>ticket[i];
            id[i]=i;
        }
        cin>>x>>a>>y>>b;

        //default x<y

        if(x>y){//swap
            long long t=x;
            x=y;
            y=t;
            t=a;
            a=b;
            b=t;
        }
        long long k;
        cin>>k;
        k*=100;//percentage k<=1e14 k*100<=1e16 long long 1e19

        sort(id+1,id+1+n,cmp);//ticket[id[i]]==面值第i大的电影票的面值

        int l=0,r=n,ans=maxn,flag=0;
        while(l<=r){
            int mid=(l+r)>>1;
            long long ret=check(mid);
            if(ret>=k){//合法
                r=mid-1;
                flag=1;
                ans=min(ans,mid);
            }
            else l=mid+1;
        }
        if(flag)    cout<<ans<<endl;
        else cout<<-1<<endl;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
const int maxn=2e5+10;
long long ticket[maxn],arr[maxn],id[maxn];
int x,a,y,b;
bool cmp(int x,int y)
{
    return ticket[x]>ticket[y];
}
long long check(int r)
{
    long long sum=0;

    int cnt1=r/(a*b);//([1,r]经过cnt1个(lcm(a,b))的点)
    int cnt2=r/b;   //defalut x<y
    int cnt3=r/a;

    if(cnt2*b>=cnt1*a*b){//x+y,y
        cnt2-=cnt1;
    }
    else{//y,x+y
        cnt2=cnt2-(cnt1-1);
    }
    if(cnt3*a>=cnt1*a*b){//x+y,x
        cnt3-=cnt1;
    }
    else{//x,x+y
        cnt3=cnt3-(cnt1-1);
    }

    if(a==b)   {cnt1=r/a;cnt2=cnt3=0;}//间隔相同时两种program指向同一点 不相同添加 将cnt1置0会出错 因为x,y值不同

    for(int i=1;i<=cnt1;i++){//x+y位置
        sum+=ticket[id[i]]*(x+y);//其实sort一遍ticket相同实现
    }
    for(int i=cnt1+1;i<=cnt1+cnt2;i++){//单独的y位置
        sum+=ticket[id[i]]*y;
    }
    for(int i=cnt1+cnt2+1;i<=cnt1+cnt2+cnt3;i++){//单独的x位置
        sum+=ticket[id[i]]*x;
    }
    return sum;
}
int main()
{
    int q;
    cin>>q;
    while(q--){
        memset(ticket,0,sizeof(ticket));
        memset(arr,0,sizeof(arr));
        memset(id,0,sizeof(id));
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>ticket[i];
            id[i]=i;
        }
        cin>>x>>a>>y>>b;

        //default x<y

        if(x>y){//swap
            int t=x;
            x=y;
            y=t;
            t=a;
            a=b;
            b=t;
        }
        long long k;
        cin>>k;
        k*=100;//percentage k<=1e14 k*100<=1e16 long long 1e19

        sort(id+1,id+1+n,cmp);//ticket[id[i]]==面值第i大的电影票的面值

        int l=0,r=n,ans=maxn,flag=0;
        while(l<=r){
            int mid=(l+r)>>1;
            long long ret=check(mid);
            if(ret>=k){//合法
                r=mid-1;
                flag=1;
                ans=min(ans,mid);
            }
            else l=mid+1;
        }
        if(flag)    cout<<ans<<endl;
        else cout<<-1<<endl;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const int INF = 1 << 30;
const int MAXN = 2e5 + 10;

typedef pair<LL, LL> P;
LL Q, n, p[MAXN], x, a, y, b, k;
LL tmp[MAXN];
priority_queue<P, vector<P>, less<P> > q, tq;
bool check(int t){
    tq = q;
    LL sum = 0, indx = n, res = 0;
    while(!tq.empty() && indx > 0 && sum < k){
        P cur = tq.top();
        tq.pop();
        if(cur.second > t) continue;
        sum += p[indx--]/100*cur.first;
        ++res;
    }
    return sum >= k;
}
int main() {
    ios::sync_with_stdio(false);
    cin >> Q;
    while(Q--) {
        while(!q.empty()) q.pop();
        cin >> n;
        for(int i = 1; i <= n; ++i)
            cin >> p[i];
        cin >> x >> a >> y >> b >> k;
        sort(p+1, p+1+n);
        ms(tmp, 0);
        for(int i = 1; i * a <= n; ++i)
            tmp[i*a] += x;
        for(int i = 1; i * b <= n; ++i)
            tmp[i*b] += y;
        for(int i = 1; i <= n; ++i)
            if(tmp[i] > 0)
                q.push(P(tmp[i], i));

        bool flag = false;
        LL l = 1, r = n,ans=MAXN;
        while(l <=r){
            LL mid = (l+r)/2;
            if(check(mid)){
                r = mid-1;
                ans=min(ans,mid);
                flag = true;}
            else l = mid+1;
        }
        if(flag)
            cout << ans << endl;
        else
            cout << -1 << endl;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<queue>
#include<string.h>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const int INF = 1 << 30;
const int MAXN = 2e5 + 10;

typedef pair<LL, LL> P;
LL Q, n, p[MAXN], x, a, y, b, k;
LL tmp[MAXN];
priority_queue<P, vector<P>, less<P> > q, tq;
bool check(int t){
    tq = q;
    LL sum = 0, indx = n, res = 0;
    while(!tq.empty() && indx > 0 && sum < k){
        P cur = tq.top();
        tq.pop();
        if(cur.second > t) continue;
        sum += p[indx--]/100*cur.first;
        ++res;
    }
    return sum >= k;
}
int main() {
    ios::sync_with_stdio(false);
    cin >> Q;
    while(Q--) {
        while(!q.empty()) q.pop();
        cin >> n;
        for(int i = 1; i <= n; ++i)
            cin >> p[i];
        cin >> x >> a >> y >> b >> k;
        sort(p+1, p+1+n);
        ms(tmp, 0);
        for(int i = 1; i * a <= n; ++i)
            tmp[i*a] += x;
        for(int i = 1; i * b <= n; ++i)
            tmp[i*b] += y;
        for(int i = 1; i <= n; ++i)
            if(tmp[i] > 0)
                q.push(P(tmp[i], i));

        bool flag = false;
        LL l = 1, r = n,ans=MAXN;
        while(l <=r){
            LL mid = (l+r)/2;
            if(check(mid)){
                r = mid-1;
                ans=min(ans,mid);
                flag = true;}
            else l = mid+1;
        }
        if(flag)
            cout << ans << endl;
        else
            cout << -1 << endl;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
long long ticket[maxn],arr[maxn],id[maxn];
int x,a,y,b;
bool cmp(int x,int y)
{
    return ticket[x]>ticket[y];
}
long long check(int r)
{
    long long sum=0;
    int cnt1=r/(a*b);//([1,r]经过cnt1个(lcm(a,b))的点)
    int cnt2=r/b-cnt1;//defalut x<y
    int cnt3=r/a-cnt1;
    if(a==b)   {cnt1=r/a;cnt2=cnt3=0;}//间隔相同时两种program指向同一点 不相同添加 将cnt1置0会出错 因为x,y值不同
    for(int i=1;i<=cnt1;i++){
        sum+=ticket[id[i]]*(x+y);//其实sort一遍ticket相同实现
    }
    for(int i=cnt1+1;i<=cnt1+cnt2;i++){
        sum+=ticket[id[i]]*y;
    }
    for(int i=cnt1+cnt2+1;i<=cnt1+cnt2+cnt3;i++){
        sum+=ticket[id[i]]*x;
    }
    return sum;
}
int main()
{
    int q;
    cin>>q;
    while(q--){
        int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>ticket[i];
            id[i]=i;
        }
        cin>>x>>a>>y>>b;
        //default x<y
        if(x>y){//swap
            int t=x;
            x=y;
            y=t;
            t=a;
            a=b;
            b=t;
        }
        long long k;
        cin>>k;
        k*=100;//percentage k<=1e14 k*100<=1e16 long long 1e19
        sort(id+1,id+1+n,cmp);//ticket[id[i]]==面值第i大的电影票的面值
        int l=0,r=n,ans=maxn,flag=0;
        while(l<=r){
            int mid=(l+r)>>1;
            long long ret=check(mid);
            if(ret>=k){//合法
                r=mid-1;
                flag=1;
                ans=min(ans,mid);
            }
            else l=mid+1;
        }
        if(flag)    cout<<ans<<endl;
        else cout<<-1<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<ll> p(n + 1);
    for (int i = 1; i <= n; i++) {
      cin >> p[i];
      p[i] /= 100;
    }
    sort(p.begin(), p.end(), greater<ll>());
    ll x, a, y, b, k;
    cin >> x >> a >> y >> b >> k;
    if (y < x) {
      swap(x, y);
      swap(a, b);
    }
    ll l = 1, r = n, ans = -1;
    while (l <= r) {
      ll mid = l + r >> 1;
      ll sum = 0, lcm = a * b / __gcd(a, b);
      ll common = mid / lcm, total = (mid / a) + (mid / b) - (mid / lcm);
      for (ll i = 0; i < common; i++) sum += p[i] * (x + y);
      for (ll i = common; i < total; i++) sum += y * p[i];
      for (ll i = total - 1; i >= total - ((mid / a) - common); i--) sum -= p[i] * (y - x);
      if (sum >= k) {
        ans = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  ll q;
  cin >> q;
  while (q--) {
    ll n;
    cin >> n;
    vector<ll> p(n);
    for (ll i = 0; i < n; i++) {
      cin >> p[i];
      p[i] /= 100;
    }
    sort(p.begin(), p.end(), greater<ll>());
    ll x, a, y, b, k;
    if (y < x) {
      swap(x, y);
      swap(a, b);
    }
    cin >> x >> a >> y >> b >> k;
    ll l = 1, r = n, ans = -1;
    while (l <= r) {
      ll mid = l + r >> 1;
      ll sum = 0, lcm = a * b / __gcd(a, b);
      ll common = mid / lcm, total = (mid / a) + (mid / b) - (mid / lcm);
      for (ll i = 0; i < common; i++) sum += p[i] * (x + y);
      for (ll i = common; i < total; i++) sum += y * p[i];
      for (ll i = total - 1; i >= total - ((mid / a) - common); i--) sum -= p[i] * (y - x);
      if (sum >= k) {
        ans = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<ll> p(n + 1);
    for (int i = 1; i <= n; i++) {
      cin >> p[i];
      p[i] /= 100;
    }
    sort(p.begin(), p.end(), greater<ll>());
    ll x, a, y, b, k;
    if (y < x) {
      swap(x, y);
      swap(a, b);
    }
    cin >> x >> a >> y >> b >> k;
    ll l = 1, r = n, ans = -1;
    while (l <= r) {
      ll mid = l + r >> 1;
      ll sum = 0, lcm = a * b / __gcd(a, b);
      ll common = mid / lcm, total = (mid / a) + (mid / b) - (mid / lcm);
      for (ll i = 0; i < common; i++) sum += p[i] * (x + y);
      for (ll i = common; i < total; i++) sum += y * p[i];
      for (ll i = total - 1; i >= total - ((mid / a) - common); i--) sum -= p[i] * (y - x);
      if (sum >= k) {
        ans = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  ll q;
  cin >> q;
  while (q--) {
    ll n;
    cin >> n;
    vector<ll> p(n);
    for (ll i = 0; i < n; i++) {
      cin >> p[i];
      //p[i] /= 100;
    }
    sort(p.begin(), p.end(), greater<ll>());
    ll x, a, y, b, k;
    if (y > x) {
      swap(x, y);
      swap(a, b);
    }
    cin >> x >> a >> y >> b >> k;
    ll l = 1, r = n, ans = -1;
    while (l <= r) {
      ll mid = l + r >> 1;
      ll sum = 0, lcm = a * b / __gcd(a, b);
      ll common = mid / lcm, total = (mid / a) + (mid / b) - common;
      for (ll i = 0; i < common; i++) sum += p[i] * (x + y);
      for (ll i = 0; i < mid / a - common; i++) sum += p[common + i] * x;
      for (ll i = 0; i < mid / b - common; i++) sum += p[common + (mid / b - common) + i] * y;
      sum /= 100;
      // for (ll i = 0; i < common; i++) sum += p[i] * (x + y);
      // for (ll i = common; i < total; i++) sum += y * p[i];
      // for (ll i = total - 1; i >= total - ((mid / a) - common); i--) sum -= p[i] * (y - x);
      if (sum >= k) {
        ans = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  ll q;
  cin >> q;
  while (q--) {
    ll n;
    cin >> n;
    vector<ll> p(n);
    for (ll i = 0; i < n; i++) {
      cin >> p[i];
      //p[i] /= 100;
    }
    sort(p.begin(), p.end(), greater<ll>());
    ll x, a, y, b, k;
    if (y < x) {
      swap(x, y);
      swap(a, b);
    }
    cin >> x >> a >> y >> b >> k;
    ll l = 1, r = n, ans = -1;
    while (l <= r) {
      ll mid = l + r >> 1;
      ll sum = 0, lcm = a * b / __gcd(a, b);
      ll common = mid / lcm, total = (mid / a) + (mid / b) - common;
      for (ll i = 0; i < common; i++) sum += p[i] * (x + y);
      for (ll i = 0; i < mid / b - common; i++) sum += p[common + i] * y;
      for (ll i = 0; i < mid / a - common; i++) sum += p[common + (mid / b - common) + i] * x;
      sum /= 100;
      // for (ll i = 0; i < common; i++) sum += p[i] * (x + y);
      // for (ll i = common; i < total; i++) sum += y * p[i];
      // for (ll i = total - 1; i >= total - ((mid / a) - common); i--) sum -= p[i] * (y - x);
      if (sum >= k) {
        ans = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  ll q;
  cin >> q;
  while (q--) {
    ll n;
    cin >> n;
    vector<ll> p(n);
    for (ll i = 0; i < n; i++) {
      cin >> p[i];
      p[i] /= 100;
    }
    sort(p.begin(), p.end(), greater<ll>());
    ll x, a, y, b, k;
    if (y < x) {
      swap(x, y);
      swap(a, b);
    }
    cin >> x >> a >> y >> b >> k;
    ll l = 1, r = n, ans = -1;
    while (l <= r) {
      ll mid = l + r >> 1;
      ll sum = 0, lcm = a * b / __gcd(a, b);
      ll common = mid / lcm, total = (mid / a) + (mid / b) - common;
      for (ll i = 0; i < common; i++) sum += p[i] * (x + y);
      for (ll i = common; i < total; i++) sum += y * p[i];
      for (ll i = total - 1; i >= total - ((mid / a) - common); i--) sum -= p[i] * (y - x);
      if (sum >= k) {
        ans = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  ll q;
  cin >> q;
  while (q--) {
    ll n;
    cin >> n;
    vector<ll> p(n);
    for (ll i = 0; i < n; i++) {
      cin >> p[i];
      p[i] /= 100;
    }
    sort(p.begin(), p.end(), greater<ll>());
    ll x, a, y, b, k;
    if (y < x) {
      swap(x, y);
      swap(a, b);
    }
    cin >> x >> a >> y >> b >> k;
    ll l = 1, r = n, ans = -1;
    while (l <= r) {
      ll mid = l + r >> 1;
      ll sum = 0, lcm = a * b / __gcd(a, b);
      ll common = mid / lcm, total = (mid / a) + (mid / b) - common;
      for (ll i = 0; i < common; i++) sum += p[i] * (x + y);
      for (ll i = 0; i < mid / b - common; i++) sum += p[common + i] * y;
      for (ll i = 0; i < mid / a - common; i++) sum += p[common + (mid / b - common) + i] * x;
      // for (ll i = 0; i < common; i++) sum += p[i] * (x + y);
      // for (ll i = common; i < total; i++) sum += y * p[i];
      // for (ll i = total - 1; i >= total - ((mid / a) - common); i--) sum -= p[i] * (y - x);
      if (sum >= k) {
        ans = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std ;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

priority_queue <ll> pq ;
ll arr[200005] ;
bool arrCheck[200005] ;
ll n, xInd, yInd, k ;
double x, y ;

bool check(ll target)
{
    while (!pq.empty()) {
        pq.pop() ;
    }
    for (int i = 1; i <= n; i++) {
        pq.push(arr[i]) ;
    }
    for (int i = 1; i <= target; i++) {
        arrCheck[i] = false ;
    }
    ll ans = 0 ;
    ll comboInd = (xInd * yInd) / __gcd(xInd, yInd) ;
    double comboVal = (x + y) / 100, xVal = x / 100, yVal = y / 100 ;
    for (int i = comboInd; i <= target; i += comboInd) {
        arrCheck[i] = true ;
        ans += ( (double)pq.top() * comboVal) ;
        pq.pop() ;
    }
    if (x > y) {
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += ( (double)pq.top() * xVal) ;
                pq.pop() ;
            }
        }
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += ( (double)pq.top() * yVal) ;
                pq.pop() ;
            }
        }
    }
    else {
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += ( (double)pq.top() * yVal) ;
                pq.pop() ;
            }
        }
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += ( (double)pq.top() * xVal) ;
                pq.pop() ;
            }
        }
    }
    if (ans >= k)   return true ;
    else    return false ;
}

int main()
{
    ll t ;
    cin >> t ;
    while (t--) {
        cin >> n ;
        for (int i = 1; i <= n; i++) {
            scanf("%lld", &arr[i]) ;
        }
        cin >> x >> xInd >> y >> yInd >> k ;
        ll L = 1, R = n, mid, ans = -1 ;
        while (L <= R) {
            mid = (L + R) / 2 ;
            if (check(mid)) {
                ans = mid ;
                R = mid - 1 ;
            }
            else {
                L = mid + 1 ;
            }
        }
        printf("%lld\n", ans) ;
    }

    return 0 ;
}


#include <bits/stdc++.h>
using namespace std ;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

priority_queue <ll> pq ;
ll arr[200005] ;
bool arrCheck[200005] ;
ll n, x, xInd, y, yInd, k ;

bool check(ll target)
{
    while (!pq.empty()) {
        pq.pop() ;
    }
    for (int i = 1; i <= n; i++) {
        pq.push(arr[i]) ;
    }
    for (int i = 1; i <= target; i++) {
        arrCheck[i] = false ;
    }
    ll ans = 0 ;
//    ll comboInd = (xInd * yInd) / __gcd(xInd, yInd) ;
//    for (int i = comboInd; i <= target; i += comboInd) {
//        arrCheck[i] = true ;
//        ans += (pq.top() * (x + y) ) ;
//        pq.pop() ;
//    }
    for (int i = 1; i <= target; i++) {
        if (i % xInd == 0 and i % yInd == 0) {
            arrCheck[i] = true ;
            ans += (pq.top() * (x + y) ) ;
            pq.pop() ;
        }
    }
    if (x > y) {
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pq.top() * x) ;
                pq.pop() ;
            }
        }
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pq.top() * y) ;
                pq.pop() ;
            }
        }
    }
    else {
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pq.top() * y) ;
                pq.pop() ;
            }
        }
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pq.top() * x) ;
                pq.pop() ;
            }
        }
    }
    if (ans >= k)   return true ;
    else    return false ;
}

int main()
{
    ll t ;
    cin >> t ;
    while (t--) {
        cin >> n ;
        for (int i = 1; i <= n; i++) {
            scanf("%lld", &arr[i]) ;
            arr[i] /= 100 ;
        }
        scanf("%lld %lld %lld %lld %lld", &x, &xInd, &y, &yInd, &k) ;
        ll L = 1, R = n, mid, ans = -1 ;
        while (L <= R) {
            mid = (L + R) / 2 ;
            if (check(mid)) {
                ans = mid ;
                R = mid - 1 ;
            }
            else {
                L = mid + 1 ;
            }
        }
        printf("%lld\n", ans) ;
    }

    return 0 ;
}


#include <bits/stdc++.h>
using namespace std ;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

priority_queue <ll> pq, pqTemp ;
ll arr[200005] ;
bool arrCheck[200005] ;
ll n, xInd, yInd, k ;
double x, y ;

bool check(ll target)
{
    ll ans = 0 ;
    pqTemp = pq ;
    for (int i = 1; i <= target; i++) {
        arrCheck[i] = false ;
    }
    ll combo = (xInd * yInd) / __gcd(xInd, yInd) ;
    double comboVal = (x + y) / 100, xVal = x / 100, yVal = y / 100 ;
    for (int i = combo; i <= target; i += combo) {
        arrCheck[i] = true ;
        ans += (pqTemp.top() * comboVal) ;
        pqTemp.pop() ;
    }
    if (x > y) {
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * xVal) ;
                pqTemp.pop() ;
            }
        }
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * yVal) ;
                pqTemp.pop() ;
            }
        }
    }
    else {
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * yVal) ;
                pqTemp.pop() ;
            }
        }
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * xVal) ;
                pqTemp.pop() ;
            }
        }
    }
    if (ans >= k)   return true ;
    else    return false ;
}

int main()
{
    ll t ;
    cin >> t ;
    while (t--) {
        while (!pq.empty()) {
            pq.pop() ;
        }
        cin >> n ;
        for (int i = 1; i <= n; i++) {
            scanf("%lld", &arr[i]) ;
            pq.push(arr[i]) ;
        }
        cin >> x >> xInd >> y >> yInd >> k ;
        ll L = 1, R = n, mid, ans = -1 ;
        while (L <= R) {
            mid = (L + R) / 2 ;
            if (check(mid)) {
                ans = mid ;
                R = mid - 1 ;
            }
            else {
                L = mid + 1 ;
            }
        }
        printf("%lld\n", ans) ;
    }

    return 0 ;
}


#include <bits/stdc++.h>
using namespace std ;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

priority_queue <ll> pq, pqTemp ;
ll arr[200005] ;
bool arrCheck[200005] ;
ll n, xInd, yInd, k ;
double x, y ;

bool check(ll target)
{
    ll ans = 0 ;
    pqTemp = pq ;
    for (int i = 1; i <= target; i++) {
        arrCheck[i] = false ;
    }
    ll combo = xInd * yInd ;
    double comboVal = (x + y) / 100, xVal = x / 100, yVal = y / 100 ;
    for (int i = combo; i <= target; i += combo) {
        arrCheck[i] = true ;
        ans += (pqTemp.top() * comboVal) ;
        pqTemp.pop() ;
    }
    if (x > y) {
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * xVal) ;
                pqTemp.pop() ;
            }
        }
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * yVal) ;
                pqTemp.pop() ;
            }
        }
    }
    else {
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * yVal) ;
                pqTemp.pop() ;
            }
        }
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * xVal) ;
                pqTemp.pop() ;
            }
        }
    }
    if (ans >= k)   return true ;
    else    return false ;
}

int main()
{
    ll t ;
    cin >> t ;
    while (t--) {
        while (!pq.empty()) {
            pq.pop() ;
        }
        cin >> n ;
        for (int i = 1; i <= n; i++) {
            scanf("%lld", &arr[i]) ;
            pq.push(arr[i]) ;
        }
        cin >> x >> xInd >> y >> yInd >> k ;
        ll L = 1, R = n, mid, ans = -1 ;
        while (L <= R) {
            mid = (L + R) / 2 ;
            if (check(mid)) {
                ans = mid ;
                R = mid - 1 ;
            }
            else {
                L = mid + 1 ;
            }
        }
        printf("%lld\n", ans) ;
    }

    return 0 ;
}


#include <bits/stdc++.h>
using namespace std ;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

priority_queue <ll> pq ;
ll arr[200005] ;
bool arrCheck[200005] ;
ll n, xInd, yInd, k ;
double x, y ;

bool check(ll target)
{
    while (!pq.empty()) {
        pq.pop() ;
    }
    for (int i = 1; i <= n; i++) {
        pq.push(arr[i]) ;
    }
    for (int i = 1; i <= target; i++) {
        arrCheck[i] = false ;
    }
    double ans = 0 ;
    ll comboInd = (xInd * yInd) / __gcd(xInd, yInd) ;
    double comboVal = (x + y) / 100, xVal = x / 100, yVal = y / 100 ;
    for (int i = comboInd; i <= target; i += comboInd) {
        arrCheck[i] = true ;
        ans += ( (double)pq.top() * comboVal) ;
        pq.pop() ;
    }
    if (x > y) {
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += ( (double)pq.top() * xVal) ;
                pq.pop() ;
            }
        }
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += ( (double)pq.top() * yVal) ;
                pq.pop() ;
            }
        }
    }
    else {
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += ( (double)pq.top() * yVal) ;
                pq.pop() ;
            }
        }
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += ( (double)pq.top() * xVal) ;
                pq.pop() ;
            }
        }
    }
    if (ans >= k)   return true ;
    else    return false ;
}

int main()
{
    ll t ;
    cin >> t ;
    while (t--) {
        cin >> n ;
        for (int i = 1; i <= n; i++) {
            scanf("%lld", &arr[i]) ;
        }
        cin >> x >> xInd >> y >> yInd >> k ;
        ll L = 1, R = n, mid, ans = -1 ;
        while (L <= R) {
            mid = (L + R) / 2 ;
            if (check(mid)) {
                ans = mid ;
                R = mid - 1 ;
            }
            else {
                L = mid + 1 ;
            }
        }
        printf("%lld\n", ans) ;
    }

    return 0 ;
}


#include <bits/stdc++.h>
using namespace std ;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

priority_queue <ll> pq ;
ll arr[200005] ;
bool arrCheck[200005] ;
ll n, x, xInd, y, yInd, k ;

bool check(ll target)
{
    while (!pq.empty()) {
        pq.pop() ;
    }
    for (int i = 1; i <= n; i++) {
        pq.push(arr[i]) ;
    }
    for (int i = 1; i <= target; i++) {
        arrCheck[i] = false ;
    }
    ll ans = 0 ;
    ll comboInd = ( (xInd * yInd) / __gcd(xInd, yInd) ) ;
    for (ll i = comboInd; i <= target; i += comboInd) {
        arrCheck[i] = true ;
        ans += (pq.top() * (x + y) ) ;
        pq.pop() ;
    }
    if (x > y) {
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pq.top() * x) ;
                pq.pop() ;
            }
        }
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pq.top() * y) ;
                pq.pop() ;
            }
        }
    }
    else {
        for (int i = yInd; i <= target; i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pq.top() * y) ;
                pq.pop() ;
            }
        }
        for (int i = xInd; i <= target; i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pq.top() * x) ;
                pq.pop() ;
            }
        }
    }
    if (ans >= k)   return true ;
    else    return false ;
}

int main()
{
    ll t ;
    cin >> t ;
    while (t--) {
        cin >> n ;
        for (int i = 1; i <= n; i++) {
            scanf("%lld", &arr[i]) ;
            arr[i] /= 100 ;
        }
        scanf("%lld %lld %lld %lld %lld", &x, &xInd, &y, &yInd, &k) ;
        ll L = 1, R = n, mid, ans = -1 ;
        while (L <= R) {
            mid = (L + R) / 2 ;
            if (check(mid)) {
                ans = mid ;
                R = mid - 1 ;
            }
            else {
                L = mid + 1 ;
            }
        }
        printf("%lld\n", ans) ;
    }

    return 0 ;
}


#include <bits/stdc++.h>
using namespace std ;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

priority_queue <ll> pq, pqTemp ;
ll arr[200005] ;
bool arrCheck[200005] ;
ll n, xInd, yInd, k ;
double x, y ;

bool check(ll target)
{
    ll ans = 0 ;
    pqTemp = pq ;
    for (int i = 1; i <= min(target, n); i++) {
        arrCheck[i] = false ;
    }
    ll combo = xInd * yInd ;
    double comboVal = (x + y) / 100, xVal = x / 100, yVal = y / 100 ;
    for (int i = combo; i <= min(target, n); i += combo) {
        arrCheck[i] = true ;
        ans += (pqTemp.top() * comboVal) ;
        pqTemp.pop() ;
    }
    if (x > y) {
        for (int i = xInd; i <= min(target, n); i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * xVal) ;
                pqTemp.pop() ;
            }
        }
        for (int i = yInd; i <= min(target, n); i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * yVal) ;
                pqTemp.pop() ;
            }
        }
    }
    else {
        for (int i = yInd; i <= min(target, n); i += yInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * yVal) ;
                pqTemp.pop() ;
            }
        }
        for (int i = xInd; i <= min(target, n); i += xInd) {
            if (!arrCheck[i]) {
                arrCheck[i] = true ;
                ans += (pqTemp.top() * xVal) ;
                pqTemp.pop() ;
            }
        }
    }
    if (ans >= k)   return true ;
    else    return false ;
}

int main()
{
    ll t ;
    cin >> t ;
    while (t--) {
        while (!pq.empty()) {
            pq.pop() ;
        }
        cin >> n ;
        for (int i = 1; i <= n; i++) {
            scanf("%lld", &arr[i]) ;
            pq.push(arr[i]) ;
        }
        cin >> x >> xInd >> y >> yInd >> k ;
        ll L = 1, R = n + 10, mid, ans = -1 ;
        while (L <= R) {
            mid = (L + R) / 2 ;
            if (check(mid)) {
                ans = mid ;
                R = mid - 1 ;
            }
            else {
                L = mid + 1 ;
            }
        }
        printf("%lld\n", ans) ;
    }

    return 0 ;
}