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 math
  import sys
  import operator as op
  from functools import reduce
  from collections import OrderedDict
  
  
  class Input:
      @staticmethod
      def string():
          return str(input())
  
      @staticmethod
      def int():
          return int(input())
  
      @staticmethod
      def list(sep=' '):
          return input().split(sep)
  
      @staticmethod
      def list_int(sep=' '):
          return list(map(int, input().split(sep)))
  
  
  class Output:
      @staticmethod
      def print(res):
          print(res)
  
      @staticmethod
      def string(res):
          print(str(res))
  
      @staticmethod
      def list(res):
          print(' '.join(str(x) for x in res))
  
  
  class Algorithms:
      @staticmethod
      def isPrime(n):
          return all(n % i != 0 for i in range(2, int(math.sqrt(n) + 1)))
  
      @staticmethod
      def getPrimeNumbers(n):
          a = [1]
          for num in range(2, n):
              if all(num % i != 0 for i in range(2, int(math.sqrt(num) + 1))):
                  a.append(num)
          return a
  
      # Факторизация - Разложение числа на простые множители
      @staticmethod
      def factorization(n):
          res = {}
          for i in range(2, n * n):
              cnt = 0
              while n % i == 0:
                  cnt += 1
                  n = n / i
              if cnt > 0:
                  res[i] = cnt
          if n > 1:
              res[n] = 1
          return res
  
      # Наибольший общий делитель (НОД)
      @staticmethod
      def gcd(a, b):
          if b == 0:
              return a
          else:
              a = a % b
              return Algorithms.gcd(b, a)
  
      # Наименьшее общее кратное (НОК)
      @staticmethod
      def lcm(a, b):
          return abs(a * b) // Algorithms.gcd(a, b)
  
      # Последовательность Фибоначчи =  0, 1, 1, 2, 3, 5, 8, 13, 21, 34
      @staticmethod
      def fibonacci(n):
          a = [0, 1]
          for i in range(2, n + 1):
              a.append(a[i - 1] - a[i - 2])
          return a[n]
  
      @staticmethod
      def z_func(s):
          n = len(s)
          z = [0] * n
          l = r = 0
          for i in range(1, n):
              if r >= i:
                  z[i] = min(z[i - l], r - i + 1)
              while z[i] + i < n and s[z[i]] == s[z[i] + i]:
                  z[i] += 1
              if i + z[i] - 1 > r:
                  l = i
                  r = i + z[i] - 1
          return z
  
      @staticmethod
      def faktorial(n):
          factorial = 1
          for i in range(3, n + 1):
              factorial *= i
              factorial = factorial % (math.pow(10, 9) + 7)
  
          return factorial
  
  
  
  def solve():
      n, m, k = Input.list_int()
      if n - m < 2 and  (n * (n - 1)) / 2 == m and k - 1 > 1:
          print('YES')
      elif n - m < 2 and (n * (n - 1)) / 2 > m and k - 1 > 2:
          print('YES')
      elif n - m < 2 and m == 0 and k - 1 > 0:
          print('YES')
      else:
          print('NO')
  
  
  #query_count = 1
  query_count = Input.int()
  while query_count:
      query_count -= 1
      solve()