#!/bin/python import sys q = int(raw_input().strip()) for a0 in xrange(q): length,c = raw_input().strip().split(' ') length,c = [int(length),int(c)] # your code goes here if c == 1 and length > 0: print '-1' elif c > length * (length - 1) / 2 or c < length - 1: print '-1' else: print 'idk :('