#include #include using namespace std; using namespace atcoder; #define popcount(x) __builtin_popcount(x) #define popcountll(x) __builtin_popcountll(x) #define sz(x) (int)x.size() #define eb emplace_back #define pb push_back #define pob pop_back #define fi first #define se second #define overload4(a, b, c, d, name, ...) name #define REP0(n) for(ll _abcde12345 = 0; _abcde12345 < (ll)(n); ++_abcde12345) #define REP1(i, n) for(ll i = 0; i < (ll)(n); ++i) #define REP2(i, a, b) for(ll i = (a); i < (ll)(b); ++i) #define REP3(i, a, b, c) for(ll i = (a); i < (ll)(b); i += (c)) #define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__) #define rrep(i, a, b) for(ll i = (a); i >= (ll)(b); --i) #define each_for(...) for (auto&& __VA_ARGS__) #define each_const(...) for (const auto& __VA_ARGS__) #define yesno(bool) if(bool) { cout << "Yes\n"; } else { cout << "No\n"; } #define ifelse(bool, x, y) if(bool) { cout << (x) << '\n'; } else { cout << (y) << '\n'; } #define all(obj) (obj).begin(), (obj).end() #define rall(obj) (obj).rbegin(), (obj).rend() #define fix fixed << setprecision(15) #define LB(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define UB(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define NP(v) next_permutation(all(v)) #define SORT(v) sort(all(v)) #define SORT2(v) sort(rall(v)) #define REV(v) reverse(all(v)) #define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end()) #define SUM(v) accumulate(all(v), 0LL) #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define COUNT(v,x) count(all(v),x) #define Mod 1000000007 #define mod 998244353 #define inf 1001001001 #define infl 1001002003004005006ll #define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr) #define drop(x) { cout << (x) << endl; return; } using ll = long long; using lint = long long; using i64 = long long; using ld = long double; using Mint = modint1000000007; using mint = modint998244353; using vi = vector; using vl = vector; using vvi = vector; using vvl = vector; using vvvi = vector; using vvvl = vector; using vvvvi = vector; using vvvvl = vector; using PII = pair; using PLL = pair; using vs = vector; using vb = vector; using vvb = vector; using vvvb = vector; using vvvvb = vector; const int dx[] = { 0,1,0,-1 }; const int dy[] = { 1,0,-1,0 }; const int dx8[] = { 0,1,0,-1,1,-1,1,-1 }; const int dy8[] = { 1,0,-1,0,1,1,-1,-1 }; templateostream &operator<<(ostream &os,const vector &v) { for(int i=0;i<(int)v.size();++i) { os<ostream &operator<<(ostream& os,const vector> &v) { for(int i=0;i<(int)v.size();++i) { for(int j=0;j<(int)v[i].size();++j) { os<istream &operator>>(istream &is,vector &v) { for(T &in:v)is>>in; return is; } templateistream &operator>>(istream &is,vector> &v) { for(vector &v2:v)for(T &in:v2)is>>in; return is; } templateinline bool chmax(T& a,const S& b){return(ainline bool chmin(T& a,const S& b){return(a>b?a=b,1:0);} long long POW(long long A,long long B) { long long ret=1; while(B>0) { if(B&1)ret*=A; A*=A; B>>=1; } return ret; } long long modpow(long long A,long long B,long long MOD) { long long ret=1; while(B>0) { if(B&1)ret=ret*A%MOD; A=A*A%MOD; B>>=1; } return ret; } bool is_prime(long long X) { for(long long i=2;i*i<=X;++i)if(X%i==0)return false; return true; } vectordivisor(long long X) { vectorret; for(long long i=1;i*i<=X;++i)if(X%i==0) { ret.push_back(i); if(i!=X/i)ret.push_back(X/i); } return ret; } vectorprime_factor(long long X) { vectorret; for(long long i=2;i*i<=X;++i) { while(X%i==0) { X/=i; ret.push_back(i); } } if(X>1)ret.push_back(X); return ret; } vectorsieve(long long X) { vectorret; vectorF(X+1); for(long long i=2;i<=X;++i)if(!F[i]) { ret.push_back(i); for(long long j=i+i;j<=X;j+=i)F[j]=true; } return ret; } /**********************************************************************************************************/ void solve(); //#define int long long signed main() { cin.tie(nullptr)->sync_with_stdio(false); cout<>T; rep(T)solve(); return 0; } ///////////////////////////////////////////////////////////// void solve() { int N,M;cin>>N>>M; dsu uf(2*N); rep(i,M) { int a,b;cin>>a>>b; uf.merge(--a,--b); } vvi A=uf.groups(); int cnt=0; rep(i,A.size())cnt+=A[i].size()%2; cout<