#1 Uva10019 - Funny Encryption Method
#include <bits/stdc++.h>
using namespace std;
int main() {
int t,x;
cin>>t;
while(t--){
cin>>x;
int y=x,ans=0,ans1=0;
while(x){
if(x%2)ans++;
x/=2;
}
int sum=0,count=0;
while(y){
int index=y%10;
sum+=pow(16,count)*index;
y/=10;
count++;
}
while(sum){
if(sum%2)ans1++;
sum/=2;
}
cout<<ans<<" "<<ans1<<endl;
}
}