#include const int N = 324; int V, E, K; int G[N][N]; void work() { int i, u, v; memset(G, 0, sizeof G); scanf("%d%d%d", &V, &E, &K); for (i = 0; i < E; ++i) scanf("%d%d", &u, &v), ++G[u][v], ++G[v][u], ++G[u][u], ++G[v][v]; if (E < K * (V - 1)) {puts("No"); return;} for (i = 1; i <= V; ++i) if (G[i][i] < K) {puts("No"); return;} puts("Yes"); } int main() { int T; for (scanf("%d", &T); T; --T) work(); return 0; }