#include <bits/stdc++.h>
using namespace std;
#define Alshoki ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define endl '\n'
#define ll long long
#define ld long double
#define print(x,z) for(int i = 0 ; i <z; ++i) cout<<x[i]<<" ";
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define wrong cout<<-1<< endl ; return ;
bool pairSort(pair<int,int> & a , pair<int,int> & b){
return a.second <= b.second;
}
vector<int> factors(int m){
vector<int> v;
for (int i = 1; i <= sqrt(m) ; ++i) {
if(m% i == 0){
v.push_back(i);
if(m/i != i)
v.push_back(m/i);
}
}
sort(v.begin(),v.end());
return v ;
}
void primeFactors(int n)
{
int c=2;
while(n>1)
{
if(n%c==0){
cout<<c<<" ";
n/=c;
}
else c++;
}
}
bool good(int cur , int goal){
if(cur == goal )return true;
if(cur<goal) return false;
if(cur % 3 == 0){
int sum = cur / 3;
return good(sum,goal) || good(cur-sum,goal);
}
return false;
}
void solve(){
int n , m; cin >> n >> m;
int ans_x = 0 , ans_y = 0;
int freq[300] = {0};
for (int i = 0; i < m; ++i) {
int x , y ; cin >> x >> y;
freq[x]++;
freq[y]++;
}
sort(freq,freq+300,greater<int>());
if(freq[0] == freq[1]) ans_y = freq[0];
else{
ans_x = freq[0];
ans_y = freq[1];
}
for (int i = 1; i < 300 ; ++i) {
if(freq[i] != freq[i-1]){
if(ans_x == 0 && freq[i]!= 1) {
ans_x = freq[i];
break;
}
}
}
if(ans_x == 0) ans_x = ans_y;
cout << ans_x << ' ' << ans_y - 1 << endl;
}
int main() {
Alshoki
ll t = 1;
cin>>t;
while(t--){
solve();
}
}
1234A - Equalize Prices Again | 1613A - Long Comparison |
1624B - Make AP | 660B - Seating On Bus |
405A - Gravity Flip | 499B - Lecture |
709A - Juicer | 1358C - Celex Update |
1466B - Last minute enhancements | 450B - Jzzhu and Sequences |
1582C - Grandma Capa Knits a Scarf | 492A - Vanya and Cubes |
217A - Ice Skating | 270A - Fancy Fence |
181A - Series of Crimes | 1638A - Reverse |
1654C - Alice and the Cake | 369A - Valera and Plates |
1626A - Equidistant Letters | 977D - Divide by three multiply by two |
1654B - Prefix Removals | 1654A - Maximum Cake Tastiness |
1649A - Game | 139A - Petr and Book |
1612A - Distance | 520A - Pangram |
124A - The number of positions | 1041A - Heist |
901A - Hashing Trees | 1283A - Minutes Before the New Year |