#include<bits/stdc++.h> #define ll long long #define ull unsigned long long #define pb push_back constint MAXN = 2e5 + 10; int a[MAXN],cnt[MAXN]; usingnamespace std;
int n,m; boolcheck(int mid){ ll res = 0; for(int i=1;i<=n;i++){ if(cnt[i] <= mid){ res += (mid - cnt[i]) / 2; } else{ res -= (cnt[i] - mid); } } return res >= 0; } intmain(){ int T; cin >> T; while(T--){ cin >> n >> m; int l = 1 , r = 0; for(int i=1;i<=n;i++){ cnt[i] = 0; } for(int i=1;i<=m;i++) { cin >> a[i]; cnt[a[i]]++; } for(int i=1;i<=n;i++){ r = max(r,cnt[i]); } while(l < r){ int mid = l + r >> 1; if(check(mid)){ r = mid; } else{ l = mid + 1; } } cout << r << endl; } }