/** * Author: AcFunction * Date: 2019-08-25 13:51:45 * Email: 3486942970@qq.com **/ #include #define ll long long #define db double #define PII pair #define pb push_back #define fi first #define se second using namespace std; const int INF = 1000000; int T, n, m, k; int dis[305][305], deg[305]; int main() { scanf("%d", &T); while(T --> 0) { int fla = 1; scanf("%d %d %d", &n, &m, &k); for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) dis[i][j] = 0; for(int i = 1; i <= n; i++) dis[i][i] = 1, deg[i] = 0; for(int i = 1; i <= m; i++) { int u, v; scanf("%d %d", &u, &v); dis[u][v]++, dis[v][u]++; deg[u]++, deg[v]++; } if(m / (n - 1) < k) { puts("No"); continue ; } for(int i = 1; i <= n; i++) { if(deg[i] < k) { puts("No"); fla = 0; break ; } } if(!fla) continue ; for(int l = 1; l <= n; l++) for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) { if(i != j && l != i && l != j) { dis[i][j] += dis[i][l] * dis[l][j]; if(dis[i][j] > k) dis[i][j] = k; } } for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { if(i != j && dis[i][j] < k) { puts("No"); fla = 0; break; } } } if(!fla) continue ; puts("Yes"); } return 0; }