Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanLines)
	for sc.Scan() {
		n, _ := strconv.ParseFloat(sc.Text(), 64)
		ans := n
		sum := n
		for i := 2; i <= 10; i++ {
			if i%2 == 0 {
				ans *= 2
				sum += ans
			} else {
				ans /= 3
				sum += ans
			}
		}
		fmt.Println(sum)
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(void){
	double a;
	while(cin >> a){
		if(cin.eof()) break;
		double sum=0;
		rep(i,10){
			sum+=a;
			if(i&1)
				a/=3.0;
			else
				a*=2.0;
		}
		cout.precision(10);
		cout << fixed << sum << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;

int main() {
	double n;
	while (cin >> n) {
		double sum = 0, a[10] = { 0 };
		sum = a[0] = n;
		for (int i = 1; i < 10; i++) {
			if ((i + 1) % 2 == 0) {
				a[i] = a[i - 1] * 2.0;
				sum += a[i];
			} else {
				a[i] = a[i - 1] / 3.0;
				sum += a[i];
			}
		}
		cout << sum << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
typedef long long ll;
typedef unsigned long long ull;

int main(){
    double num;
    while(~scanf("%lf",&num)){
        double ans = num;
        double bef = num;
        rep(i,9){
           if(i % 2 == 1){
                ans += bef / 3;
                bef = bef / 3;
           }
           else{
                ans += bef * 2;
                bef = bef * 2;
           }
        }
        printf("%lf\n",ans);
    }
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;

int main(){
  double a[11],ans;
  while(cin>>a[1]){
   
    ans=a[1];
    for(int i=2;i<11;i++){
      if(i%2){
	a[i]=a[i-1]/3.0;
      }else{
	a[i]=a[i-1]*2.0;
      }
      ans+=a[i];
    }
    printf("%.8f\n",ans);
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.seq", "r", stdin);
	string str = "";
	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		vector <double> a(10, 0.0 );
		stringstream ss(str);
		ss >> a[0];
		int i;
		for (i = 1; i < 10; ++i){
			if (i % 2 != 0){
				a[i] = 2.*a[i-1];
			}else{
				a[i] = a[i-1]/3.;
			} // end if
		} // end for
		double res = 0.0;
		for (i = 0; i < 10; ++i){
			res += a[i];
		} // end for

		cout << res << endl;
	} // end loop
		
	return 0;
}

C++: #include <cstdio>
#include <iostream>
using namespace std;

int main()
{
  double b;
  while(cin >> b)
    {
      double a = b;
      b *= 2; 
      a += b;
      b /= 3; 
      a += b;
      b *= 2; 
      a += b;
      b /= 3; 
      a += b;
      b *= 2; 
      a += b;
      b /= 3; 
      a += b;
      b *= 2; 
      a += b;
      b /= 3; 
      a += b;
      b *= 2; 
      a += b;
      printf("%.8f\n", a);

      if(b>10)break;
    }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
using namespace std;

int main(){
    double a;

    while(cin>>a){
        double sum=a;

        for(int n=2;n<=10;n++){
            if(n&1){
                sum+=a/3.0;
                a/=3.0;
            }else{
                sum+=a*2.0;
                a*=2.0;
            }
        }

        cout<<setprecision(8)<<setiosflags(ios::fixed)<<sum<<endl;
    }
    
    return 0;
}

C++: #include <cstdio>
#include<iostream>
 
using namespace std;
  
int main(void){
 
	long double a,before,sum;
 
    while(cin>>a){
		sum=0;
      for(int i=0;i<5;i++){
		  if(i==0) before=a;
		  else before=before/3;
		  sum+=before;
		  before=before*2;
		  sum+=before;
	  }
	  printf("%f\n",sum);
    }
 
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<algorithm>
#include<functional>
using namespace std;

 
int main()
{
	double a=0;
	cin>>a;
	
	double s=0;
	
	s=a;
	for(int i=0;i<4;i++)
	{
	a=2*a;
	s=s+a;
	a=a/3;
	s=s+a;

	}
	s=s+a*2;
	cout<<s<<endl;
    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;

main(){
  double a, s;
  while( cin >> a ){
    s = a;
    for ( int i = 2; i <= 10; i++ ){
      if ( i % 2 == 0 ) a *= 2;
      else a /= 3;
      s += a;
    } 
    printf("%.8f\n", s);
  }
}

C++: #include <iostream>
#include <cstdio>
using namespace std;

int main(){
    double a;
    while(cin>>a){
        double s=a;
        for(int i=2; i<=10; i++){
            if(i%2==0){
                a*=2;
            } else {
                a/=3;
            }
            s+=a;
        }
        printf("%.10f\n",s);
    }
}

C++: #include <iostream>
#include <cstdio>
using namespace std;

int main(void){
	double x;

	while(cin>>x){
		double sum = x;
		for(int i=0;i<9;i++){
			if(i % 2 == 0) x *= 2;
			else x /= 3;
			sum += x;
		}

		printf("%.8lf\n",sum);
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main() {
  double b[11];
  while(cin >> b[1]) {
    for(int i = 2; i <= 10; ++i) {
      if(i % 2 == 0) b[i] = b[i-1] * 2.0;
      else b[i] = b[i-1] / 3.0;
    }
    double s = 0.0;
    for(int i = 1; i <= 10; ++i) s += b[i];
    printf("%.10f\n", s);
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
	double a[11];
	double sum;
	while (cin >> a[1])
	{
		sum = a[1];
		for (int i = 2; i < 11; i++)
		{
			if (i % 2 == 0)
			{
				a[i] = 2 * a[i-1];
			}
			else
			{
				a[i] = a[i-1] / 3;
			}
			sum += a[i];
		}
		cout << setprecision(8) << sum << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(void)
{
	double a[16];
	int i;
	double total;
	
	while (scanf("%lf", &a[0]) != EOF){
		total = a[0];
		for (i = 1; i < 10; i++){
			if (i % 2 == 0){
				a[i] = a[i - 1] / 3;
			}
			if (i % 2 == 1){
				a[i] = a[i - 1] * 2;
			}
			total += a[i];
		}
		printf("%lf\n", total);
	}
	return (0);
}

C++: #include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int n;
string x;
//char x[8];
int mn, mx;

int main()
{
  cin >> n;

  while(n--){
    cin >> x;
    //    sort(x, x+8);                   sscanf(x, "%d", &mn);
    //    sort(x, x+8, greater<char>());  sscanf(x, "%d", &mx);
    sort(ALL(x));                   mn = atoi(x.c_str());
    sort(ALL(x), greater<char>());  mx = atoi(x.c_str());
    cout << mx - mn << endl;
  }

  return 0;
}

C++: #include<cstdio>
using namespace std;
int main(){
  
  double a;
  while(scanf("%lf",&a) != EOF){
    printf("%lf\n",7.81481481*a);
  }

  return (0);
}