#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int *input = new int[n];
int *answer = new int[n];
for (int i = 0; i < n; i++) {
int a, b;
scanf("%d %d", &a, &b);
input[i] = a;
answer[i] = b;
}
for (int j = 0; j < n; j++){
int sum = 0;
for(int k = 1; k <= input[j]; k++){
sum += k;
}
if (sum == answer[j]) printf("YES\n");
else printf("NO\n");
}
delete [] input;
delete [] answer;
return 0;
}