Tomya is a girl. She loves Chef Ciel very much.

Tomya like a positive integer p, and now she wants to get a receipt of Ciel's restaurant whose total price is exactly p.
The current menus of Ciel's restaurant are shown the following table.
Name of Menupriceeel flavored water1deep-fried eel bones2clear soup made with eel livers4grilled eel livers served with grated radish8savory egg custard with eel16eel fried rice (S)32eel fried rice (L)64grilled eel wrapped in cooked egg128eel curry rice256grilled eel over rice512deluxe grilled eel over rice1024eel full-course2048

Note that the i-th menu has the price 2i-1 (1 ≤ i ≤ 12).

Since Tomya is a pretty girl, she cannot eat a lot.
So please find the minimum number of menus whose total price is exactly p.
Note that if she orders the same menu twice, then it is considered as two menus are ordered. (See Explanations for details)

-----Input-----

The first line contains an integer T, the number of test cases.
Then T test cases follow.
Each test case contains an integer p.

-----Output-----

For each test case, print the minimum number of menus whose total price is exactly p.

-----Constraints-----

1 ≤ T ≤ 5

1 ≤ p ≤ 100000 (105)

There exists combinations of menus whose total price is exactly p.

-----Sample Input-----
4
10
256
255
4096

-----Sample Output-----
2
1
8
2

-----Explanations-----

In the first sample, examples of the menus whose total price is 10 are the following:

1+1+1+1+1+1+1+1+1+1 = 10 (10 menus)

1+1+1+1+1+1+1+1+2 = 10 (9 menus)

2+2+2+2+2 = 10 (5 menus)

2+4+4 = 10 (3 menus)

2+8 = 10 (2 menus)

Here the minimum number of menus is 2.

In the last sample, the optimal way is 2048+2048=4096 (2 menus).
Note that there is no menu whose price is 4096.

Difficulty: interview

Starter code:

Solutions:
t= int(input())
while(t>0):
    n = int(input())
    m=0
    m=n//(2**11)
    n%=(2**11)
    while(n>0):
        num=n%2
        m+=num
        n//=2
    print(m)
    t-=1

n=int(input())
for i in range(n):
    p=int(input())
    menu=0
    if p>2048:
        menu=(p//2048)-1
        p=p-(2048*menu)
    while p!=0:
        if p%2!=0:
            menu=menu+1 
        p=p//2
    print(menu)


# cook your dish here
t= int(input())
while(t>0):
    n = int(input())
    cnt=0
    cnt=n//(2**11)
    n%=(2**11)
    while(n>0):
        num=n%2
        cnt+=num
        n//=2
    print(cnt)
    t-=1

for _ in range (int(input())):
    cash = int(input())
    menu = 11
    count = 0
    while(cash>0):
        if(cash>=pow(2,menu)):
            cash -= pow(2,menu)
            count += 1
        else:
            menu -= 1 
    print(count)

# cook your dish here
t=int(input())
l=[2048,1024,512,256,128,64,32,16,8,4,2,1]
for i in range(t):
    n=int(input())
    r=0
    while(n>0):
        for j in l:
            if(n>=j):
                r+=n//j
                n%=j
    print(r)

# cook your dish here
for _ in range(int(input())):
    n=[1,2,4,8,16,32,64,128,256,512,1024,2048]
    p=int(input())
    c=0
    while p>=1:
        m=[]
        for q in n:
            if(p>=q):
                m.append(p-q)
        p=min(m)
        c+=1
    print(c)

# cook your dish here
for _ in range(int(input())):
    n=[1,2,4,8,16,32,64,128,256,512,1024,2048]
    p=int(input())
    c=0
    while p>=1:
        m=[]
        for q in n:
            if(p>=q):
                m.append(p-q)
        p=min(m)
        c+=1
    print(c)

# cook your dish here
x=int(input())
for i in range(x):
    y=int(input())
    c=0
    p=11
 
    while(y>0):
        if(y>=pow(2,p)):
            y=y-pow(2,p)
            c=c+1
        else:
            p=p-1
    print(c)        

# cook your dish here
t=int(input())
while t!=0:
    n=int(input())
    res=0
    i=11
    ct=0
    while n:
        res+=n//2**i
        n=n%2**i
        i-=1
    print(res)
    t=t-1

s=int(input())
b=[2048,1024,512,256,128,64,32,16,8,4,2,1]
for _ in range(s):
    v=0
    y=int(input())
    i=0
    while y:
        v+=y//b[i]
        y=y%b[i]
        i=i+1
    print(v)

# cook your dish here
s=int(input())
b=[2048,1024,512,256,128,64,32,16,8,4,2,1]
for _ in range(s):
    v=0
    y=int(input())
    i=0
    while y:
        v+=y//b[i]
        y=y%b[i]
        i=i+1
    print(v)

# cook your dish here
t=int(input())
l=[2048,1024,512,256,128,64,32,16,8,4,2,1]
for _ in range(t):
    c=0
    n=int(input())
    i=0
    while n:
        c+=n//l[i]
        n=n%l[i]
        i=i+1
    print(c)

def bill(p):
    sum=0
    t=0
    i=0
    m=0
    while 1:
        if sum==p:
            break
        elif sum<p:
            sum=sum+y[i]
            m=m+1
        elif sum>p:
            sum=sum-y[i]
            i=i+1
            m=m-1
    return m

y=[2048,1024,512,256,128,64,32,16,8,4,2,1]
n=int(input())
for i in range(n):
    p=int(input())
    print(bill(p))

N=int(input())
for i in range(N):
    p=[2048,1024,512,256,128,64,32,16,8,4,2,1]
    a=int(input())
    count=0
    for i in p:
        if(a>=i):
            count=count+a//i
            a=a%i
    print(count)

N=int(input())
for i in range(N):
    p=[2048,1024,512,256,128,64,32,16,8,4,2,1]
    a=int(input())
    count=0
    for i in p:
        if(a>=i):
            count=count+a//i
            a=a%i
    print(count)
    


t=int(input())
i=0
while i<t:
	n=int(input())
	c=0
	if n>2048:
		c=n//2048
		n=n-(c*2048)
	while n>0:
		r=n%2
		if r==1:
			c+=1
		n=n//2
	print(c)
	i+=1

# cook your dish here
t=int(input())
for i in range(t):
    p=int(input())
    l=[1,2,4,8,16,32,64,128,256,512,1024,2048]
    c=0 
    
    while p>=1:
        m=[]
        for i in l:
            if p>=i:
                m.append(p-i)
           
        p= min(m)
        
        c+=1
    print(c)
    


# cook your dish here
t = int(input())

for i in range(t):
    a = int(input())
    l=[1,2,4,8,16,32,64,128,256,512,1024,2048]
    z=0
    while a>=1:
        m=[]
        for i in l:
            if a>=i:
                m.append(a-i)
           
        a= min(m)
        
        z+=1
    print(z)
    


try:
    t=int(input())
    for t in range(t):
         P=[2048,1024,512,256,128,64,32,16,8,4,2,1]
         n=int(input())
         count=0
         for i in P:
             if(n>=i):
                 count=count+n//i
                 n=n%i
         print(count)
except:
    pass

# cook your dish here
t=int(input())
for t in range(t):
    P=[2048,1024,512,256,128,64,32,16,8,4,2,1]
    n=int(input())
    count=0
    for i in P:
        if(n>=i):
            count=count+n//i
            n=n%i
    print(count)

# cook your dish here
for i in range(int(input())):
  a=int(input())
  j=11
  c=0
  while a>0:
    b=a//(2**j)
    c+=b
    a=a%(2**j)
    j-=1
  print(c) 

# cook your dish here
a=[]
for x in range(0,12):
    a.append(2**x)
    
for y in range(int(input())):
    n=int(input())
    if n%2==0:
        k=0
    else:
        k=1
    while n!=1 and n!=0:
        for x in range(11,0,-1):
            if n==a[x]:
                k+=1
                n=0
                break
            elif a[x]<n:
                n-=a[x]
                k+=1
                break
    print(k)
    


T=int(input())
ans=[]
def fun1(p,i):
    n=int(p/(2**i))
    return p-(n*(2**i))
def fun2(p,i):
    n=int(p/(2**i))
    return n
ans=[]
for x in range(T):
    p=int(input())
    sum=0
    for y in range(11,-1,-1):
        sum=sum+fun2(p,y)
        p=fun1(p,y)
    ans.append(sum)
for z in ans:
    print(z)

# cook your dish here
T=int(input())
ans=[]
def fun1(p,i):
    n=int(p/(2**i))
    return p-(n*(2**i))
def fun2(p,i):
    n=int(p/(2**i))
    return n
ans=[]
for x in range(T):
    p=int(input())
    sum=0
    for y in range(11,-1,-1):
        sum=sum+fun2(p,y)
        p=fun1(p,y)
    ans.append(sum)
for z in ans:
    print(z)

# cook your dish here
for i in range(int(input())):
  a=int(input())
  j=11
  c=0
  while a>0:
    b=a//(2**j)
    c+=b
    a=a%(2**j)
    j-=1
  print(c)