description: CQXYM wants to create a connected undirected graph with n nodes and m edges, and the diameter of the graph must be strictly less than k-1. Also, CQXYM doesn't want a graph that contains self-loops or multiple edges (i.e. each edge connects two different vertices and between each pair of vertices there is at most one edge).
  
  The diameter of a graph is the maximum distance between any two nodes.
  
  The distance between two nodes is the minimum number of the edges on the path which endpoints are the two nodes.
  
  CQXYM wonders whether it is possible to create such a graph.
  
  Input
  
  The input consists of multiple test cases. 
  
  The first line contains an integer t (1 ≤ t ≤ 10^5) — the number of test cases. The description of the test cases follows.
  
  Only one line of each test case contains three integers n(1 ≤ n ≤ 10^9), m, k (0 ≤ m,k ≤ 10^9).
  
  Output
  
  For each test case, print YES if it is possible to create the graph, or print NO if it is impossible. You can print each letter in any case (upper or lower).
  
  Example
  
  Input
  
  
  5
  1 0 3
  4 5 3
  4 6 3
  5 4 1
  2 1 1
  
  
  Output
  
  
  YES
  NO
  YES
  NO
  NO
  
  Note
  
  In the first test case, the graph's diameter equal to 0.
  
  In the second test case, the graph's diameter can only be 2.
  
  In the third test case, the graph's diameter can only be 1.
solution: 
  /*
      Author : Kartikey Rana
      from MSIT New Delhi
   */
  import java.util.*;
  import java.util.Arrays;
  import java.util.Collections;
  import javax.sql.rowset.serial.SerialArray;
  import javax.swing.text.html.HTMLDocument.HTMLReader.PreAction;
  import java.io.*;
  import java.math.*;
  import java.sql.Array;;
  
  public class Main {
  	static class FR {
  
  		BufferedReader br;
  		StringTokenizer st;
  
  		public FR() {
  			br = new BufferedReader(new InputStreamReader(System.in));
  		}
  
  		String next() {
  			while (st == null || !st.hasMoreElements()) {
  				try {
  					st = new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					e.printStackTrace();
  				}
  			}
  			return st.nextToken();
  		}
  
  		int nextInt() {
  			return Integer.parseInt(next());
  		}
  
  		long nextLong() {
  			return Long.parseLong(next());
  		}
  
  		double nextDouble() {
  			return Double.parseDouble(next());
  		}
  
  		String nextLine() {
  			String str = "";
  			try {
  				str = br.readLine();
  			} catch (IOException e) {
  				e.printStackTrace();
  			}
  			return str;
  		}
  
  		// NEXT INT ARRAY
  
  		int[] NIA(int n) {
  			int arr[] = new int[n];
  			for (int i = 0; i < n; i++)
  				arr[i] = nextInt();
  			return arr;
  		}
  
  		// NEXT DOUBLE ARRAY
  
  		double[] NDA(int n) {
  			double arr[] = new double[n];
  			for (int i = 0; i < n; i++)
  				arr[i] = nextDouble();
  			return arr;
  		}
  
  		// NEXT LONG ARRAY
  
  		long[] NLA(int n) {
  			long[] arr = new long[n];
  			for (int i = 0; i < n; i++)
  				arr[i] = nextLong();
  			return arr;
  		}
  
  		// NEXT STRING ARRAY
  
  		String[] NSA(int n) {
  			String[] arr = new String[n];
  			for (int i = 0; i < n; i++)
  				arr[i] = next();
  			return arr;
  		}
  
  		// NEXT CHARACTER ARRAY
  
  		char[] NCA(int n) {
  			char[] arr = new char[n];
  			String s = sc.nextLine();
  
  			for (int i = 0; i < n; i++)
  				arr[i] = s.charAt(i);
  			return arr;
  		}
  
  	}
  
  //*************************  FR CLASS ENDS **********************************
  	
  	static long mod = (long) (1e9 + 7);
  
  	public static int[] sieve(int n) {
  		
  		int[] primes = new int[n+1];
  		for(int i = 0; i <= n; i++) {
  			primes[i] = i;
  		}
  		
  		for(int i = 2; i< n; i++) {
  			if(primes[i] < 0)
  				continue;
  			if((long)i*(long)i > n)
  				break;
  			for(int j = i*i; j < n; j++) {
  				if(primes[j] > 0 && primes[j]%primes[i] == 0)
  					primes[j] = -primes[j];
  			}
  		}
  		return primes;
  	}
  	
  
  	static int lcm(int a, int b){
  		 return (int) ((a / gcd(a, b)) * b);
  	 }
  	
  	static long gcd(long a, long b) {
  		 if (b == 0)
  	          return a;
  		 
  	     return gcd(b, a%b);
  	}
  
  
  	static long[][] ncr(int n, int k) {
  		long C[][] = new long[n + 1][k + 1];
  		int i, j;
  
  		// Calculate value of Binomial
  		// Coefficient in bottom up manner
  		for (i = 0; i <= n; i++) {
  			for (j = 0; j <= Math.min(i, k); j++) {
  				// Base Cases
  				if (j == 0 || j == i)
  					C[i][j] = 1;
  
  				// Calculate value using
  				// previously stored values
  				else
  					C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  			}
  		}
  
  		return C;
  	}
  
  	static long modInverse(long a, long m) {
  		long g = gcd(a, m);
  
  		return power(a, m - 2, m);
  
  	}
  
  	static long power(long x, long y, long m) {
  		if (y == 0)
  			return 1;
  		long p = power(x, y / 2, m) % m;
  		p = (int) ((p * (long) p) % m);
  		if (y % 2 == 0)
  			return p;
  		else
  			return (int) ((x * (long) p) % m);
  	}
  
  	static int XOR(int n) {
  		if (n % 4 == 0)
  			return n;
  
  		if (n % 4 == 1)
  			return 1;
  
  		if (n % 4 == 2)
  			return n + 1;
  
  		return 0;
  	}
  
  	/* ***************************************************************************************************************************************************/
  
  	static FR sc = new FR();
  	static StringBuilder sb = new StringBuilder();
  
  	public static void main(String args[]) throws IOException {
  
  		
  		
  		int tc = sc.nextInt();
  //		int tc = 1;
  		while (tc-- > 0) {
  			TEST_CASE();
  		}
  		sb.setLength(sb.length() - 1);
  		System.out.println(sb);
  	}
  
  
  	static void TEST_CASE() throws IOException {
  		//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  		
  		long n = sc.nextLong();
          long m = sc.nextLong();
          long k = sc.nextLong();
          boolean ans = true;
          int min = 0;
          if (m > 0) min = 2;
          if (m > 0 && m == (1l * n * (n - 1) / 2)) min = 1;
          ans &= m >= n - 1;
          ans &= m <= (1l * n * (n - 1) / 2);
          ans &= k - 1 > min;
          if (ans) sb.append("YES");
          else sb.append("NO");
          sb.append("\n");
  		
  			
  		
  	}
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  