#include<iostream>
#include<algorithm>
using namespace std;
int weight[400];//简单的贪心,只要排序后体重小的去和体重大的一起就好了

int main()
{
	int N;
	int n, w;
	while (cin >> N)
	{
		while (N--)
		{
			while (cin >> w >> n)
			{
				int count = 0;
				for (int i = 0; i < n; i++)
					cin >> weight[i];
				sort(weight, weight + n);
				int k = n - 1;
				for (int i = 0; i <=k; i++)
				{
					count++;//顺序搞对就a了
					for (int j = k; j >i; j--)
					{
						k --;
						if (weight[i] + weight[j] <= w)
						{
							break;
						}
						count++;
					}
				}
				cout << count << endl;
			}
		}
	}
	return 0;
}