c#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int T; cin >> T; while(T--){ int N, M; cin >> N >> M; for(int i = 0; i < M; i++){ int A, B; cin >> A >> B; } cout << N - 1 << "\n"; } return 0; }