#include using namespace std; const int maxn = 300 + 5; int w[maxn][maxn], g[maxn]; bool v[maxn], del[maxn]; void add_edge(int x, int y, int c) { w[x][y] += c; w[y][x] += c; } pair phase(int n) { memset(v, false, sizeof(v)); memset(g, 0, sizeof(g)); int s = -1, t = -1; while (true) { int c = -1; for (int i = 0; i < n; ++i) { if (del[i] || v[i]) continue; if (c == -1 || g[i] > g[c]) c = i; } if (c == -1) break; v[c] = true; s = t, t = c; for (int i = 0; i < n; ++i) { if (del[i] || v[i]) continue; g[i] += w[c][i]; } } return make_pair(s, t); } int mincut(int n) { int cut = 1e9; memset(del, false, sizeof(del)); for (int i = 0; i < n - 1; ++i) { int s, t; tie(s, t) = phase(n); del[t] = true; cut = min(cut, g[t]); for (int j = 0; j < n; ++j) { w[s][j] += w[t][j]; w[j][s] += w[j][t]; } } return cut; } int main() { int t; scanf("%d", &t); while (t--) { int n, m, k; scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) w[i][j] = 0; } while (m--) { int u, v; scanf("%d%d", &u, &v); --u, --v; add_edge(u, v, 1); } if (mincut(n) >= k) printf("Yes\n"); else printf("No\n"); } }