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: import java.util.*;
  import java.io.*;
  public class Sol{
   
  /*   
  ->check n=1, int overflow , array bounds , all possibilites(dont stuck on 1 approach)
  ->Problem = Observation(constraints(m<=n/3 or k<=min(100,n)) 
             + Thinking + Technique (seg_tree,binary lift,rmq,bipart,dp,connected comp etc)
  ->solve or leave it (- tutorial improves you in minimal way -)
  */
   
  public static void main (String []args) {
  //precomp();
  
  int times=ni();while(times-->0){solve();}out.close();}
  
  static void solve(){
   
    long n=ni();long m=ni();long k=ni();
  
    if(n==1){long ans=k;
      if(m==0)ans=0;
      if(ans<=k-2)out.println("YES");
      else out.println("NO");
    }
    else{
      long ans=0;long c=n*(n-1);
      
      if(m>=n-1 && 2*m<c){ans=2;}
      else if(2*m==c ){ans=1;}
      else {ans=k;}
    
      if(ans<=k-2)out.println("YES");
      else out.println("NO");
    }
  }
  
  //-----------------Utility--------------------------------------------
  
  static long gcd(long a,long b){if(b==0)return a; return gcd(b,a%b);}
   
  static int Max=Integer.MAX_VALUE; static long mod=1000000007;
   
  //static int v(char c){return (int)(c-'a');}
   
  public static long power(long x, long y )
      {
          //0^0 = 1
          long res = 1L;
          x = x%mod;
          while(y > 0)
          {
              if((y&1)==1)
                  res = (res*x)%mod;
              y >>= 1;
              x = (x*x)%mod;
          }
          return res;
      }
   
  /*static class Pair implements Comparable<Pair>{
          int id;int value;Pair next;
          public Pair(int id,int value) {
           
            this.id=id;this.value=value;next=null;
          }
          @Override
          public int compareTo(Pair p){return Long.compare(value,p.value);}
      }
  */ 
   
  //----------------------I/O---------------------------------------------
   
  static InputStream inputStream = System.in;
  static OutputStream outputStream = System.out;
  static FastReader in=new FastReader(inputStream);
  static PrintWriter out=new PrintWriter(outputStream);
   
  static class FastReader 
  { 
    BufferedReader br; 
    StringTokenizer st; 
   
          FastReader(InputStream is) {
              br = new BufferedReader(new InputStreamReader(is));
          }
   
    public String next() 
    { 
        while (st == null || !st.hasMoreElements()) 
        { 
            try
            { 
                st = new StringTokenizer(br.readLine()); 
            } 
            catch (IOException  e) 
            { 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
   
    public int nextInt() 
    { 
        return Integer.parseInt(next()); 
    } 
   
    public long nextLong() 
    { 
        return Long.parseLong(next()); 
    } 
   
   public  double nextDouble() 
    { 
        return Double.parseDouble(next()); 
    } 
   
   
    String nextLine() 
    { 
        String str = ""; 
        try
        { 
            str = br.readLine(); 
        } 
        catch (IOException e) 
        { 
            e.printStackTrace(); 
        } 
        return str; 
    } 
  }
  //Only for Integer Input
  /*static int ni() {
          try {
              boolean in = false;
              int res = 0;
              for (;;) {
                  int b = System.in.read() - '0';
                  if (b >= 0) {
                      in = true;
                      res = 10 * res + b;
                  }
                  else if (in)
                      return res;
              }
          } catch (IOException e) {
              throw new Error(e);
          }
      }*/
  static int ni(){return in.nextInt();}
  static long nl(){return in.nextLong();}
  static double nd(){return in.nextDouble();}
  static String ns(){return in.nextLine();}
  }