def main():
t = int(input())
allans = []
for _ in range(t):
n, m, k = readIntArr()
k -= 2 lo = n - 1
hi = (n * (n - 1)) // 2
if not lo <= m <= hi:
allans.append('NO')
continue
if n == 1:
if k >= 0:
allans.append('YES')
else:
allans.append('NO')
continue
if n == 2:
if k >= 1:
allans.append('YES')
else:
allans.append('NO')
continue
if k <= 0:
ans = 'NO'
elif k == 1:
if m == hi:
ans = 'YES'
else:
ans = 'NO'
else:
ans = 'YES'
allans.append(ans)
multiLineArrayPrint(allans)
return
import sys
input=sys.stdin.buffer.readline
def oneLineArrayPrint(arr):
print(' '.join([str(x) for x in arr]))
def multiLineArrayPrint(arr):
print('\n'.join([str(x) for x in arr]))
def multiLineArrayOfArraysPrint(arr):
print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))
def readIntArr():
return [int(x) for x in input().split()]
def makeArr(defaultValFactory,dimensionArr): dv=defaultValFactory;da=dimensionArr
if len(da)==1:return [dv() for _ in range(da[0])]
else:return [makeArr(dv,da[1:]) for _ in range(da[0])]
def queryInteractive(a, b, c):
print('? {} {} {}'.format(a, b, c))
sys.stdout.flush()
return int(input())
def answerInteractive(x1, x2):
print('! {} {}'.format(x1, x2))
sys.stdout.flush()
inf=float('inf')
from math import gcd,floor,ceil
import math
for _abc in range(1):
main()
// author Vardhan Gacche
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define read(a, n) \
for (int i = 0; i < n; i++) \
cin >> a[i];
#define show(a) \
for (auto x : a) \
cout << x << " "; \
cout << endl;
#define sort(a) \
sort(a.begin(), a.end());
char get(int i)
{
return 'a' + i - 1;
}
int returnVal(char x)
{
return (int)x - 96;
}
int gcd(int a, int b)
{
return b == 0 ? a : gcd(b, a % b);
}
int lcm(int a, int b)
{
return (a * b) / gcd(a, b);
}
void setIO(string name = "")
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if (name.size())
{
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
void view(vector<vector<char>> a)
{
for (vector<char> x : a)
{
show(x);
}
}
int main()
{
// setIO("reduce");
int t;
cin >> t;
while (t--)
{
long long int n, m, k, count = 0, x = 0;
cin >> n >> m >> k;
x = (n * (n - 1)) / 2;
if(m < n - 1 || m > x)
{
no;
}
else if(n == 1)
{
if(k > 1 && m <= 0)
{
yes;
}
else
{
no;
}
}
else if(m < x)
{
if(k > 3)
{
yes;
}
else
{
no;
}
}
else
{
if(k > 2)
{
yes;
}
else
{
no;
}
}
}
return 0;
}
1703G - Good Key Bad Key | 1705A - Mark the Photographer |
1707A - Doremy's IQ | 1706B - Making Towers |
1325B - CopyCopyCopyCopyCopy | 1649C - Weird Sum |
1324B - Yet Another Palindrome Problem | 525A - Vitaliy and Pie |
879A - Borya's Diagnosis | 1672B - I love AAAB |
1673A - Subtle Substring Subtraction | 1345A - Puzzle Pieces |
711A - Bus to Udayland | 779B - Weird Rounding |
1703D - Double Strings | 1704C - Virus |
63A - Sinking Ship | 1704B - Luke is a Foodie |
298B - Sail | 239A - Two Bags of Potatoes |
1704E - Count Seconds | 682A - Alyona and Numbers |
44A - Indian Summer | 1133C - Balanced Team |
1704A - Two 0-1 Sequences | 1467A - Wizard of Orz |
1714E - Add Modulo 10 | 1714A - Everyone Loves to Sleep |
764A - Taymyr is calling you | 1714B - Remove Prefix |