import math
t=input()
while t :
n=input()
x=n
a=0
while x>1:
a+=1
x/=2
print 2*(n-2**(int)(math.log(n,2)))+1,
print (int)(math.log(n,2))
print 2*(n-2**a)+1,
print a
t-=1
CmltcG9ydCBtYXRoCnQ9aW5wdXQoKQp3aGlsZSB0IDoKCW49aW5wdXQoKQoJeD1uCglhPTAKCXdoaWxlIHg+MToKCQlhKz0xCgkJeC89MgoJcHJpbnQgMioobi0yKiooaW50KShtYXRoLmxvZyhuLDIpKSkrMSwKCXByaW50IChpbnQpKG1hdGgubG9nKG4sMikpCglwcmludCAyKihuLTIqKmEpKzEsCglwcmludCBhCgl0LT0x