int cnt; inlinevoidadd_edge(int from, int to, int cap) { e[++cnt].nxt = fb[from]; fb[from] = cnt; e[cnt].to = to; e[cnt].cap = cap; e[++cnt].nxt = fb[to]; fb[to] = cnt; e[cnt].to = from; e[cnt].cap = 0; }
int n, m, S, T;
structEDGE { int from, to; } ee[maxn];
inlinevoidjiantu(int k) { memset(fb, 0xff, sizeof(fb)); cnt = -1; for (int i = 1; i <= n; ++i) if (i != k) add_edge(i, T, 2); for (int i = 1; i <= m; ++i) { add_edge(i + n, ee[i].from, inf); add_edge(i + n, ee[i].to, inf); add_edge(S, i + n, 1); } }
int dep[maxn];
inlineboolbfs() { memset(dep, 0x3f, sizeof(dep)); for (int i = S; i <= T; ++i) first[i] = fb[i]; queue<int> q; q.push(S); dep[S] = 0; while (!q.empty()) { int now = q.front(); q.pop(); for (int i = first[now]; ~i; i = e[i].nxt) { int to = e[i].to; if (dep[to] >= inf && e[i].cap > 0) { q.push(to); dep[to] = dep[now] + 1; } } } return dep[T] < inf; }
inlineintdfs(int now, int limit) { if (now == T || !limit) return limit; int flow = 0; for (int i = first[now]; ~i; i = e[i].nxt) { first[now] = i; int to = e[i].to, f; if (dep[to] == dep[now] + 1 && (f = dfs(to, min(limit, e[i].cap)))) { e[i].cap -= f; e[i ^ 1].cap += f; limit -= f; flow += f; if (!limit) break; } } return flow; }
inlineintDinic() { int ans = 0; while (bfs()) ans += dfs(S, inf); return ans; }
inlinevoidsolve() { read(n), read(m); S = 0; T = n + m + 1; for (int i = 1; i <= m; ++i) read(ee[i].from), read(ee[i].to); int ans = 0; for (int i = 1; i <= n; ++i) { jiantu(i); ans = max(ans, m - Dinic()); } puts(ans > 0 ? "No" : "Yes"); }
intmain() { int TT; read(TT); while (TT--) solve(); return0; }