/*--.--.--.--.--.--.--.--.--.--.--.--.--*
* By-Rohit Singh *
* CS , MNNIT Allahabad *
* rohitmnnit1459@gmail.com *
*--.--.--.--.--.--.--.--.--.--.--.--.--*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <limits.h>
#include <assert.h>
//#include <unordered_map>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define null NULL
#define ll long long
#define llu unsigned long long
#define MAX 200005
#define mod 1000000007
#define inf 1e16
#define pp pair <int, int>
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <ldb, ldb> pdd;
const db PI = 3.141592653589793238;
#define abs(x) ((x)>0?(x):-(x))
//#define pop pop_back()
#define scan(x) scanf("%d",&x)
#define print(x) printf("%d\n",x)
#define scanll(x) scanf("%lld",&x)
#define scanllu(x) scanf("%llu",&x)
#define printll(x) printf("%lld\n",x)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define PER(i,a,b) for(int i=b;i>=a;i--)
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//**********************************************HAPPY CODDING*****************************************************//
int ind;
llu arr[100], n, ans, ex, gc, num;
void compute(llu n) {
int i, j;
ind = arr[0] = 0;
while (n) {
arr[++ind] = n%10;
n /= 10;
}
for (i = 1,j = ind ; i <= j ; i++,j--) {
swap(arr[i], arr[j]);
}
REP(i,1,ind) {
arr[i] ^= arr[i-1];
}
}
llu gcd(llu a, llu b) {
return (!a ? b : gcd(b%a, a));
}
int main() {
int t, rem;
scan(t);
while (t--) {
scanllu(n);
compute(n);
ans = 0;
num = n;
while (n) {
ind--;
ans += (llu)(n/10)*(llu)45;
rem = n%10;
ex = 0;
while (rem) {
ex += (arr[ind]^r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