#include <stdio.h>
#include <iostream>
#include <map>
#include <assert.h>

using namespace std;

int main()
{
	freopen("joust.in", "r", stdin);
	//freopen("joust.out", "w", stdout);
	
	int test;
	cin >> test;
	for(int t=0; t<test; t++)
	{
		long long k, p1, p2, p3;
		cin >> k >> p1 >> p2 >> p3;

		assert(1 < k && k <= 1000ll*1000*1000*1000*1000*10);
		assert(0 <= p1 && p1 <= 100);
		assert(0 <= p2 && p2 <= 100);
		assert(0 <= p3 && p3 <= 100);
		assert(p1 + p3 <= 100);

		p2 = 100 - p2;

		long long res = 1000ll*1000*1000*1000*1000*100;
		int resi = -1;

		for(int i=1; i<k; i++)
		{
			long long m1 =  2*p1*i + 2*p2*(k-i) + i*p3;
			long long m2 =  2*(100-p1-p3)*i + 2*(100-p2)*(k-i) + i*p3;

			long long d = abs(m1-m2);
			if (res > d)
			{
				res = d;
				resi = i;
			}
		}

		cout << resi << endl;
	}

	return 0;
}

