// AOJ 1261: Mobile Computing
// 2017.12.18 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define EPS 1e-6

typedef struct { int w; double l, r; } ST;
ST st[20]; int top;

int sz; double r;
double ans;
int w[12];
char f[12];
int p[12];

double calc()
{
	int i;
	double x, y;
	ST *a, *b, c;

	top = 0;
	for (i = 0; i < sz; i++) {
		if (w[p[i]] >= 0) st[top].w = w[p[i]], st[top].l = st[top].r = 0, top++;
		else {
			if (top < 2) return -1;
			a = &st[--top], b = &st[--top];
			c.w = a->w + b->w;
			x = b->w / (double)c.w, y = a->w / (double)c.w;
			c.l = a->l + x; if (c.l < b->l - y) c.l = b->l - y;
			c.r = a->r - x; if (c.r < b->r + y) c.r = b->r + y;
			st[top++] = c;
		}
	}
	if (top > 1) return -1;
	return st[0].l + st[0].r;
}

void permutation(int i, int k)
{
	int j;
	double w;

	p[i] = k;
	if (i == sz-1) {
		w = calc();
		if ((fabs(w-r) <= EPS || w <= r) && w > ans) ans = w;
	} else {
		f[k] = 0;
		for (j = 0; j < sz; j++) if (f[j]) permutation(i+1, j);
		f[k] = 1;
	}
}

int main()
{
	int cno, s, i;

	scanf("%d", &cno);
	while (cno--) {
		scanf("%lf%d", &r, &s);
		sz = 0;
		for (i = 0; i < s; i++) scanf("%d", w + sz++);
		for (i = 1; i < s; i++) w[sz++] = -1;
		if (r < 1.0 || s < 2) { puts("-1"); continue; }

		ans = -1;
		memset(f, 1, sizeof(f));
		for (i = 0; i < sz; i++) permutation(0, i);
		if (ans < 0) puts("-1");
		else printf("%.16lf\n", ans);
	}
 	return 0;
}