#include <stdio.h>
#include <sstream>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cassert>
#include <ctime>
#include <numeric>
#include <string.h>
using namespace std;
#pragma comment(linker, "/STACK:20000000")

typedef vector<int> vi;
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()

string problem_name = "a";

void init(){
  freopen((problem_name+".in").c_str(),"rt",stdin);
 // freopen((problem_name+".out").c_str(),"wt",stdout);
}

double dp[1<<18][18];
double mas[20][20];
int n;
double go(int s, int w, int c)
{
    if (c==1)
    {
        return (s>>w)&1;
    }
    if (dp[s][w]>-.1) return dp[s][w];
    double res=0;

    for (int i=0;i<n;i++) if ((1<<i)&s)
    for (int j=i+1;j<n;j++) if ((1<<j)&s)
    {
        res+= go((1<<j)^s,w,c-1)*mas[i][j];
        res+= go((1<<i)^s,w,c-1)*(1-mas[i][j]);
        res+= go((1<<i)^s,w,c-1)*mas[j][i];
        res+= go((1<<j)^s,w,c-1)*(1-mas[j][i]);
    }

    return dp[s][w] = res/(c*(c-1));
}

int main()
{
    //init();

    //int n;
    scanf("%d",&n);
    for (int i=0;i<n;i++)
        for (int j=0;j<1<<n;j++)
            dp[j][i]=-1;

    for (int i=0;i<n;i++)
    for (int j=0;j<n;j++)
        scanf("%lf",&mas[i][j]);

    for (int i=0;i<n;i++)
        printf("%.6lf\n",go((1<<n)-1,i,n));

  return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include<fstream>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <string.h>
#define rep(x,n) for(int x=0;x<n;++x)
#define rep1(i,s) for(int i = 0; i < (int)s.size

#define mem(a, b) memset(a, b, sizeof(a))

#define mp(x,y) make_pair(x,y)
#define getBit(code, i) (code & (1 << i))
#define setBit(code, i) (code | (1 << i))
#define xetBit(code, i) (code & ~(1 << i))
#define PI acos(-1.0)
#define oo (int)10e7
#define rd(x) scanf("%d", &x)
#define rdfile(x) freopen(x, "r", stdin)
#define wtfile(x) freopen(x, "w", stdout)
using namespace std;

#define negmod(x, mod) ((x + mod) % mod)

double table[1<<20];

int n;

double p[20][20];

double solve(int mask, int pairs)
{
    if(mask == (1<<n) - 1)
        return 1.0;

    double &ret = table[mask];

    if(ret >= 0.0)
        return ret;
    ret = 0;

    rep(i, n) if(getBit(mask, i))
        rep(j, n) if(!getBit(mask, j))
        ret += solve(setBit(mask, j), pairs + 1) * p[i][j];

    return ret /= pairs * (pairs + 1) / 2.0;
}

int main()
{
    cin >> n;
    rep(i, n) rep(j, n) cin >> p[i][j];
    memset(table, -1, sizeof table);

    rep(i, n) {
        cout << fixed << setprecision(6) << solve(1<<i, 1) << " ";
    }
    cout << endl;
    return 0;
}


// c16e.cpp : Defines the entry point for the console application.
//

#include <iostream>
using namespace std;
int n;
double a[18][18];
double b[262144];
int h[18],x;
void poed (int y)
{
	int g=0;
	for (int j=0;j<n;j++) if ((y/h[j])%2==1) g++;
	for (int j=0;j<n;j++)
	{
		if ((y/h[j])%2==1)
		{
			for (int k=0;k<n;k++)
			{
				if ((y/h[k])%2==1)
				{
					b[y-h[j]]=b[y-h[j]]+b[y]*a[k][j]/(g*(g-1)/2);
				}
			}
		}
	}
}
int main()
{
	cout.setf(ios::fixed);
	cout.precision(7);
	cin >> n;
	for (int i=0;i<n;i++) for (int j=0;j<n;j++) cin >> a[i][j];
	h[0]=1;
	for (int i=1;i<n;i++) h[i]=h[i-1]*2;
	x=h[n-1]*2-1;
	b[x]=1;
	for (int i=0;i<x;i++) b[i]=0;
	for (int i=x;i>=1;i--) poed(i);
	for (int i=0;i<n;i++)
	{
		if (i==n-1) cout << b[h[i]];
		else cout << b[h[i]] << ' ';
	}
	return 0;
}


// c16e.cpp : Defines the entry point for the console application.
//

#include <iostream>
using namespace std;
int n;
double a[18][18];
double b[262144];
int h[18],x;
void poed (int y)
{
	for (int j=0;j<n;j++)
	{
		if ((y/h[j])%2==0)
		{
			for (int k=0;k<n;k++)
			{
				if ((y/h[k])%2==0)
				{
					b[y-h[j]]=b[y-h[j]]+b[y]*a[j][k];
				}
			}
		}
	}
}
int main()
{
	cin >> n;
	for (int i=0;i<n;i++) for (int j=0;j<n;j++) cin >> a[i][j];
	h[0]=1;
	for (int i=1;i<n;i++) h[i]=h[i]*2;
	x=h[n-1]*2-1;
	b[x]=1;
	for (int i=0;i<x;i++) b[i]=0;
	for (int i=x;i>=1;i--) poed(i);
	for (int i=0;i<n;i++)
	{
		if (i==n-1) cout << b[h[i]];
		else cout << b[h[i]] << ' ';
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
#include <ctime>
#include <cstdlib>
#include <set>
#include <sstream>
#include <queue>
#include <functional>
#include <memory>
#include <assert.h>

#define sqr(x) ((x)*(x))
#define ll long long

using namespace std;

const int maxn=20;

int n;
double a[maxn][maxn];
double d[1<<maxn];

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	cin >> n;
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			cin >> a[i][j];
	d[(1<<n)-1]=1;
	for (int mask=(1<<n)-1; mask; mask--) {
		int cnt=0;
		for (int i=0; i<n; i++)
			cnt+=(mask&(1<<i))>0;
		for (int i=0; i<n; i++) if (mask&(1<<i)) {
			for (int j=0; j<n; j++) if ((mask&(1<<j)) && i!=j) {
				d[mask^(1<<j)]+=d[mask]*a[i][j]/(cnt*(cnt-1)/2.0);
			}
		}
	}
	for (int i=0; i<n; i++)
		printf("%.10lf ",d[1<<i]);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<cmath>
using namespace std;
double ar[19][19];
double dp[(1<<18)]={0};
int n;
int co(int x){
	int ret=0;
	while(x){
		ret+=x%2;
		x/=2;
	}
	return ret;
}
int main(){
	cin>>n;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			cin>>ar[i][j];
	dp[0]=1;
	for(int msk=1;msk<(1<<n);++msk){
		int cn= co(msk);
		int cnn=cn;
		cn=n-cn+1;
		double pos=cn*(cn-1)/2;
		pos=1.0/pos;
		for(int i=0;i<n;++i){
			if(msk&(1<<i)){
				for(int j=0;j<n;++j)
					{
						if(msk&(1<<j))continue;
					dp[msk]+=dp[msk^(1<<i)]*pos*ar[j][i];
				}
			}

		}}
	for(int i=0;i<n;++i)
		printf("%.6lf ",dp[((1<<n)-1)^(1<<i)]);
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:64000000")
#include<iostream>
#include<fstream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<set>
#include<list>
#include<map>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<bitset>
#include<sstream>
#include<time.h>
#include<numeric>
#include<functional>

using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#define INF  ((1 << 31) - 1)
#define LLINF  ((ll)((1LL << 63) - 1))
#define eps (1e-9)
#define million 1000000
#define PI 3.14159265358979323846
#define sz(v) ((int)(v).size())
#define MP make_pair
#define PB push_back
#define all(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<vector<double> > a(n, vector<double> (n, -1.0));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			scanf("%lf", &a[i][j]);
	vector<double> prob((1<<n), 0.0);
	prob[(1 << n) - 1] = 1.0;
	for (int mask = (1 << n) - 1; mask > 0; --mask) {
		int bitc = 0;
		for (int i = 0 ;i < n; ++i)
			if ((mask >> i) & 1)
				++bitc;
		for (int i = 0 ;i < n; ++i) {
			if ((mask >> i) & 1) {
				for (int j = i + 1; j < n; ++j) {
					if ((mask >> j) & 1) {
						prob[mask ^ (1 << i)] += 2.0 / bitc / (bitc - 1)* prob[mask] * a[j][i];
						prob[mask ^ (1 << j)] += 2.0 / bitc / (bitc - 1)* prob[mask] * a[i][j];
					}
				}
			}
		}
	}
	for (int i = 0 ;i < n; ++i) {
		printf("%lf\n", prob[1 << i]);
	}
	return 0;
}


#include <cstdio>
#include <cstring>

int n;
double p[18][18];
int pow2[31];

double dp[1<<18];

double solve( int status ){

    if( dp[status] >= 0.0 )
        return dp[status];

    int hasDie = 0;
    for( int i = 0 ; i < n ; i ++ )
        if( status & pow2[i] )
            hasDie ++;

    double res = 0.0;
    for( int i = 0 ; i < n ; i ++ )
        if( status & pow2[i] )
            for( int j = 0 ; j < n ; j ++ )
                if( (status & pow2[j]) == 0)
                    res += solve( status - pow2[i] )*p[j][i]  / (double)( ( n - hasDie + 1 ) * ( n - hasDie ) / 2 )  ;

    return dp[status] = res;
}

void initPow2( void ){

    pow2[0] = 1;
    for( int i = 1 ; i < 31 ; i ++ )
        pow2[i] = 2*pow2[i-1];

    return ;
}

int main( void ){

    initPow2();

    while( scanf("%d",&n) != EOF ){

        for( int i = 0 ; i < n ; i ++ )
            for( int j = 0 ; j < n ; j ++ )
                scanf("%lf",&p[i][j]);

        for( int j = 0 ; j < (1<<n) ; j ++ )
            dp[j] = -1.0;
        dp[0] = 1.0;

        for( int i = 0 ; i < n ; i ++ ){
            double res = solve( (1<<n) - 1 - pow2[i] );
            //for( int j = n-1 ; j > 1 ; j -- )
            //  res /= ( double) j;
            printf( "%.6lf%c" , res , i == n-1 ? '\n':' ' );
        }
    }

    return 0;
}


#include <cstdio>
#include <cstring>

int n;
double p[18][18];
int pow2[31];

double dp[18][1<<18];

double solve( int index , int status ){

    if( dp[index][status] >= 0.0 )
        return dp[index][status];

    //int hasDie = 0;
    //for( int i = 0 ; i < n ; i ++ )
    //  if( status & pow2[i] )
    //      hasDie ++;

    double res = 0.0;
    for( int i = 0 ; i < n ; i ++ )
        if( status & pow2[i] )
            res += solve( index , status - pow2[i] )*p[index][i] /* / (double)( ( n - hasDie + 1 ) * ( n - hasDie ) / 2 ) */ ;

    return dp[index][status] = res;
}

void initPow2( void ){

    pow2[0] = 1;
    for( int i = 1 ; i < 31 ; i ++ )
        pow2[i] = 2*pow2[i-1];

    return ;
}

int main( void ){

    initPow2();

    while( scanf("%d",&n) != EOF ){

        for( int i = 0 ; i < n ; i ++ )
            for( int j = 0 ; j < n ; j ++ )
                scanf("%lf",&p[i][j]);

        for( int i = 0 ; i < n ; i ++ )
            for( int j = 0 ; j < (1<<n) ; j ++ )
                dp[i][j] = -1.0;

        for( int i = 0 ; i < n ; i ++ )
            dp[i][0] = 1.0;

        for( int i = 0 ; i < n ; i ++ ){
            double res = solve( i , (1<<n) - 1 - pow2[i] );
            for( int j = n-1 ; j > 1 ; j -- )
                res /= ( double) j;
            printf( "%.6lf%c" , res , i == n-1 ? '\n':' ' );
        }
    }

    return 0;
}


#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include <cstring>
using namespace std ;
#define REP(i,k,n) for (int i=k;i<n;i++)
#define REV(i,k,n) for (int i=k;i>=n;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define eps 1e-11

double s [22][22] ;
bool v [(1<<19)] ;
double dp [(1<<19)] ;
int n ;

double rec (int mask) {

    if ( mask == (1<<n)-1 )
		return 1. ;

    double &res = dp [mask] ;
    if ( v [mask] ) return res ; v[mask] = true ;

    res = 0. ;
    int Sz = 0 ;

    REP (i,0,n) {
        if ( (1<<i) & mask ) {
			Sz ++ ;
            REP (j,0,n)  {
                if (((1<<j) & mask) == 0) {
                    res += rec ((1<<j) | mask) * s[i][j] ;
                }
            }
        }
    }
	Sz = (Sz * (Sz + 1))/2   ;
    res /=(double) Sz;
    return res ;
}

int main () {
    //freopen ("c.in","r",stdin) ;
    cin >> n ;

    REP (i,0,n) REP (j,0,n) cin >> s[i][j] ;

    REP (i,0,n) {
        if ( i ) printf (" ") ;
        printf ("%.6lf",rec (1<<i)) ;
    }
    printf ("\n") ;
}


#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include <cstring>
using namespace std ;
#define REP(i,k,n) for (int i=k;i<n;i++)
#define REV(i,k,n) for (int i=k;i>=n;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define eps 1e-11

double s [22][22] ;
bool v [(1<<19)] ;
double dp [(1<<19)] ;
int n ;
int M ;

double rec (int mask) {
    if ( (mask & (1<<M)) == 0 ) return 0 ;
    if ( mask == (1<<M) ) return 1. ;

    double &res = dp [mask] ;
    if ( v [mask] ) return res ;

    res = 0. ;
    int Sz = 0 ;
    REP (i,0,n) {
        if ( (1<<i) & mask ) {
			Sz++;
            REP (j,0,n)  if ( j != i ) {
                if (((1<<j) & mask)) {
                    res += rec ((1<<j) ^ mask) * s[i][j] ;
                }
            }
        }
    }
	-- Sz ;
	Sz = (Sz + 1) * Sz / 2 ;
    res /=(double) Sz;
    return res ;
}

int main () {
    //freopen ("c.in","r",stdin) ;
    cin >> n ;
    REP (i,0,n) REP (j,0,n) cin >> s[i][j] ;

    REP (i,0,n) {
        if ( i ) printf (" ") ;
        M = i ;
        memset (v,0,sizeof v) ;
        printf ("%.6lf",rec ((1<<n)-1)) ;
    }
    printf ("\n") ;
}


#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include <cstring>
using namespace std ;
#define REP(i,k,n) for (int i=k;i<n;i++)
#define REV(i,k,n) for (int i=k;i>=n;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define eps 1e-11

double s [22][22] ;
bool v [(1<<19)] ;
double dp [(1<<19)] ;
int n ;
int M ;

double rec (int mask) {
    if ( (mask & (1<<M)) == 0 ) return 0 ;
    if ( mask == (1<<M) ) return 1. ;

    double &res = dp [mask] ;
    if ( v [mask] ) return res ; v[mask] = true ;

    res = 0. ;
    int Sz = 0 ;
    REP (i,0,n) {
        if ( (1<<i) & mask ) {
			Sz++;
            REP (j,0,n)  if ( j != i ) {
                if (((1<<j) & mask)) {
                    res += rec ((1<<j) ^ mask) * s[i][j] ;
                }
            }
        }
    }
	-- Sz ;
	Sz = (Sz + 1) * Sz / 2 ;
    res /=(double) Sz;
    return res ;
}

int main () {
    //freopen ("c.in","r",stdin) ;
    cin >> n ;
    REP (i,0,n) REP (j,0,n) cin >> s[i][j] ;

    REP (i,0,n) {
        if ( i ) printf (" ") ;
        M = i ;
        memset (v,0,sizeof v) ;
        printf ("%.6lf",rec ((1<<n)-1)) ;
    }
    printf ("\n") ;
}


//#define MYDEBUG
//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>

#define MOD 1000000007
#define INF 1000000001
#define EPS 1e-6
#define HASH_POW 37
const double PI = acos(-1.0);

using namespace std;

int n;
double p[18][18];
double dp[1 << 18];

int main()
{
	//cin.sync_with_stdio(0);
	#ifdef MYDEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
	#else
	//freopen("weakconn.in", "rt", stdin);
	//freopen("weakconn.out", "wt", stdout);
	#endif

	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			scanf("%lf", &p[i][j]);
	dp[(1 << n) - 1] = 1;
	for (int i = (1 << n) - 1; i > 0; --i)
	{
		for (int x = 0; x < n - 1; ++x)
		{
			if (i & (1 << x))
			{
				for (int y = x + 1; y < n; ++y)
				{
					if (i & (1 << y))
					{
						dp[i - (1 << y)] += dp[i]*p[x][y];
						dp[i - (1 << x)] += dp[i]*p[y][x];
					}
				}
			}
		}
	}
	double tmp = 0;
	for (int i = 0; i < n; ++i)
		tmp += dp[1 << i];
	for (int i = 0; i < n; ++i)
		printf("%.7lf ", dp[1 << i]/tmp);

	#ifdef MYDEBUG
		cout << "\nTime = " << fixed << setprecision(3) << double(clock()) / CLOCKS_PER_SEC << endl;
	#endif
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:10034217728")
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
#include <utility>
#include <ctime>
#include <string>
#include <sstream>
#include <queue>
#include <cstring>

using namespace std;
typedef long long ll;
typedef long double ld;
#define ZERO(x) memset((x), 0, sizeof(x))
#define NEGATE(x) memset((x), 255, sizeof(x))
#define mp make_pair
#define mt(a, b, c) mp(a, mp(b, c))

const int M = 1 << 18;
const int N = 18;

double dp[N][M];

int n;

int lives(int mask) {
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (!(mask >> i & 1))
			res++;
	}
	return res;
}

double a[N][N];

double f(int k, int mask) {
	double& res = dp[k][mask];
	if (res != -1) return res;
	int t = lives(mask);
	if (t == 1) {
		if (mask >> k & 1) return res = 0;
		return res = 1;
	}
	res = 0;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (mask >> i & 1) continue;
			if (mask >> j & 1) continue;
			double prob = 1.0 / (t * (t - 1) / 2);
			res += prob * (a[i][j] * f(k, mask | 1 << j) + a[j][i] * f(k, mask | 1 << i));
		}
	}
	return res;
}

int main()
{
#ifdef XXX
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			dp[i][j] = -1;
	}

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) cin >> a[i][j];
	}

	for (int i = 0; i < n; i++) printf("%.15lf ", f(i, 0));

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:10034217728")
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
#include <utility>
#include <ctime>
#include <string>
#include <sstream>
#include <queue>
#include <cstring>

using namespace std;
typedef long long ll;
typedef long double ld;
#define ZERO(x) memset((x), 0, sizeof(x))
#define NEGATE(x) memset((x), 255, sizeof(x))
#define mp make_pair
#define mt(a, b, c) mp(a, mp(b, c))

const int M = 1 << 18;
const int N = 18;

double dp[M];

int n;

int ones(int mask) {
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (mask >> i & 1)
			res++;
	}
	return res;
}

double a[N][N];

/*double f(int k, int mask) {
	double& res = dp[k][mask];
	if (res != -1) return res;
	int t = lives(mask);
	if (t == 1) {
		if (mask >> k & 1) return res = 0;
		return res = 1;
	}

	res = 0;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (mask >> i & 1) continue;
			if (mask >> j & 1) continue;
			double prob = 1.0 / (t * (t - 1) / 2);
			res += prob * (a[i][j] * f(k, mask | 1 << j) + a[j][i] * f(k, mask | 1 << i));
		}
	}
	return res;
}*/

double f(int mask) {
	double& res = dp[mask];
	if (res != -1) return res;
	int t = ones(mask);
	if (t == n) {
		return res = 1;
	}
	t++;
	res = 0;
	double prob = 1.0 / (t * (t - 1) / 2);
	for (int i = 0; i < n; i++) {
		if (!(mask >> i & 1)) continue;
		//i - alive
		for (int j = 0; j < n; j++) {
			if (mask >> j & 1) continue;
			//j - dead
			res += prob * a[i][j] * f(mask | 1 << j);
		}
	}
	return res;
}

int main()
{
#ifdef XXX
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	for (int j = 0; j < M; j++)
		dp[j] = -1;

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) cin >> a[i][j];
	}

	for (int i = 0; i < n; i++) printf("%.15lf ", f(1 << i));

	return 0;
}


#include <stdio.h>
#include <math.h>
double a[20][20];
double probval[1<<18];
double probpair[1<<18];
int n;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			scanf("%lf",&a[i][j]);

	for(int i=0;i<n;i++)
		for(int j=0;j<(1<<n);j++)
		{

		}
	probval[(1<<n)-1]=1;

	for(int m=1;m<(1<<n);m++)
	{
		double ct=0;
		for(int i=0;i<n;i++)
			if((m>>i)&1)
				ct++;
		probpair[m]=1/(0.5*ct*(ct+1));
	}

	for(int m=(1<<n)-2;m>=1;m--)
	{
		probval[m]=0;
		for(int b=0;b<n;b++)
		{
			if((m>>b)&1)
			{
				for(int c=0;c<n;c++)
				{
					if(!((m>>c)&1))
						probval[m]+=probval[m|(1<<c)]*a[b][c]*probpair[m];
				}
			}

		}
	}

	for(int i=0;i<n;i++)
		printf("%lf ",probval[(1<<i)]);
	printf("\n");

}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <exception>
#include <numeric>

using namespace std;

typedef long long lo;
typedef vector< vector<long long> > vvl;
typedef vector< long long> vl;
typedef pair<lo, lo> ll;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef pair<long, pair<long, long>> lll;
typedef vector<lll> vlll;
typedef vector<vvl> vvvl;
typedef vector<set<long>> vs;

lo n;
double dp[1100100];
double a[100][100];

bool hasBit(lo mask, lo b){
	return mask & (1<<b);
}
lo countBits(lo mask){
	lo ans=0;
	for (lo i=0;i<n;i++)
		if (hasBit(mask, i)) ans++;
	return ans;
}

double f(lo mask){
	if (dp[mask]>-1) return dp[mask];
	double sum=0;
	for (lo i=0;i<n;i++)
		for (lo j=0;j<n;j++)
			if (!hasBit(mask, i) && hasBit(mask, j))
				sum+=f(mask | (1<<i)) * a[j][i];
	sum*=2;
	sum/=countBits(mask) * (countBits(mask) +1);
	return dp[mask]=sum;
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	scanf("%I64d", &n);
	for (lo i=0;i<(1<<n);i++)
		dp[i]=-2;
	dp[(1<<n)-1]=1;
	for (lo i=0;i<n;i++){
		for (lo j=0;j<n;j++)
			scanf("%lf", &a[i][j]);
	}
	for (lo i=0;i<n;i++)
		printf("%lf ", f(1<<i));

	return 0;
}


// esta3anna 3al sha2a belAllah ..
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<sstream>
#include<limits.h>
#include<iomanip>
#include<cstring>
#include<bitset>
#include<fstream>
#include<cmath>
#include<cassert>
#include <stdio.h>
#include<ctype.h>
using namespace std;
#define rep(i,n,m) for(int i = (int)(n), _m = (int)(m); i < _m; ++ i)
#define rrep(i,n,m) for(int i = (int)(n), _m = (int)(m); i >= _m; -- i)
#define foreach(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz size()
#define pb push_back
#define mp make_pair
#define mems(arr, v) memset(arr, v, sizeof arr)
#define setBit(mask, bit) ((mask) | (1LL << (bit)))
#define resetBit(mask, bit) ((mask) & (~(1LL << (bit))))
#define flipBit(mask, bit) ((mask) ^ (1LL << (bit)))
#define is0(mask, bit)(((mask) & (1LL << (bit))) == 0)
#define is1(mask, bit)(((mask) & (1LL << (bit))) != 0)
#define removeLastBit(mask) ((mask) & ((mask) - 1LL))
#define firstBitOn(mask) ((mask) & ~((mask) - 1LL))
#define grayCode(mask) ((mask) ^ ((mask) << 1LL))
#define repSubMasks(subMask, mask) for(ll subMask = (ll)(mask), _mask = subMask; subMask; subMask = _mask & (subMask - 1))
int countBits(long long mask) {int res = 0; while(mask) mask &= (mask - 1), ++ res; return res;}
string toString(long long n) {stringstream ss; ss << n; return ss.str();}
long long toNumber(string s) {stringstream ss; long long n; ss << s; ss >> n; return n;}
#define INT_MAX  1000000000
#define INT_MIN -1000000000
#define INF 1000000000
#define EPS 1e-9
#define MOD 1000000007
#define debug(x) cout << #x << " : " << x << endl
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define Read() freopen("input.txt","r",stdin)
#define Write() freopen("output.txt","w",stdout)
ld p[18][18];
ld dp[1 << 18];
int n, indx;
ld rec(int mask) {
    if((mask & (1 << indx)) == 0)
        return 0;
    if(mask == (1 << indx))
        return 1;
    ld &res = dp[mask];
    if(res == res)
        return res;
    res = 0;
    int ss = 0;
    rep(i, 0, n)
        if(mask & (1 << i))
            rep(j, i + 1, n)
                if((mask & (1 << j))) {
                    res += rec(mask & ~(1 << j)) * p[i][j];
                    res += rec(mask & ~(1 << i)) * p[j][i];
                    ++ ss;
                }
    res /= ss;
    return res;
}
int main() {
  //  Read();
    while(cin >> n) {
        rep(i, 0, n)
            rep(j, 0, n)
                cin >> p[i][j];
        rep(i, 0, n) {
            indx = i;
            mems(dp, -1);
            cout << fixed << setprecision(6) << rec((1 << n) - 1) << ' ';
        }
        cout << endl;
    }
}


// esta3anna 3al sha2a belAllah ..
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<sstream>
#include<limits.h>
#include<iomanip>
#include<cstring>
#include<bitset>
#include<fstream>
#include<cmath>
#include<cassert>
#include <stdio.h>
#include<ctype.h>
using namespace std;
#define rep(i,n,m) for(int i = (int)(n), _m = (int)(m); i < _m; ++ i)
#define rrep(i,n,m) for(int i = (int)(n), _m = (int)(m); i >= _m; -- i)
#define foreach(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz size()
#define pb push_back
#define mp make_pair
#define mems(arr, v) memset(arr, v, sizeof arr)
#define setBit(mask, bit) ((mask) | (1LL << (bit)))
#define resetBit(mask, bit) ((mask) & (~(1LL << (bit))))
#define flipBit(mask, bit) ((mask) ^ (1LL << (bit)))
#define is0(mask, bit)(((mask) & (1LL << (bit))) == 0)
#define is1(mask, bit)(((mask) & (1LL << (bit))) != 0)
#define removeLastBit(mask) ((mask) & ((mask) - 1LL))
#define firstBitOn(mask) ((mask) & ~((mask) - 1LL))
#define grayCode(mask) ((mask) ^ ((mask) << 1LL))
#define repSubMasks(subMask, mask) for(ll subMask = (ll)(mask), _mask = subMask; subMask; subMask = _mask & (subMask - 1))
int countBits(long long mask) {int res = 0; while(mask) mask &= (mask - 1), ++ res; return res;}
string toString(long long n) {stringstream ss; ss << n; return ss.str();}
long long toNumber(string s) {stringstream ss; long long n; ss << s; ss >> n; return n;}
#define INT_MAX  1000000000
#define INT_MIN -1000000000
#define INF 1000000000
#define EPS 1e-9
#define MOD 1000000007
#define debug(x) cout << #x << " : " << x << endl
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define Read() freopen("input.txt","r",stdin)
#define Write() freopen("output.txt","w",stdout)
ld p[18][18];
ld dp[1 << 18][18];
int n;
ld rec(int mask, int indx) {
    if((mask & (1 << indx)) == 0)
        return 0;
    if(mask == (1 << indx))
        return 1;
    ld &res = dp[mask][indx];
    if(res == res)
        return res;
    res = 0;
    int ss = 0;
    rep(i, 0, n)
        if(mask & (1 << i))
            rep(j, i + 1, n)
                if((mask & (1 << j))) {
                    res += rec(mask & ~(1 << j), indx) * p[i][j];
                    res += rec(mask & ~(1 << i), indx) * p[j][i];
                    ++ ss;
                }
    res /= ss;
    return res;
}
int main() {
  //  Read();
    while(cin >> n) {
        rep(i, 0, n)
            rep(j, 0, n)
                cin >> p[i][j];
        mems(dp, -1);
        rep(i, 0, n)
            cout << fixed << setprecision(6) << rec((1 << n) - 1, i) << ' ';
        cout << endl;
    }
}


#include <iostream>
#include <algorithm>

using namespace std;

double g[20][20];
double f[600000];
int c[600000];

bool Check(int x,int y,int k)
{
	if((k&(1<<x))!=0)
		return false;
	if((k&(1<<y))!=0)
		return false;
	return true;
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			scanf("%lf",&g[i][j]);
	memset(f,0,sizeof(f));
	f[0]=1.0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			memset(c,0,sizeof(c));
			for(int k=0;k<((1<<n)-1);k++)
			{
				if(Check(i,j,k)==false)
					continue;
				f[(k|(1<<j))]+=f[k]*g[i][j];
				c[(k|(1<<j))]++;
				f[(k|(1<<i))]+=f[k]*g[j][i];
				c[(k|(1<<i))]++;
			}
			for(int k=0;k<((1<<n)-1);k++)
			{
				if(c[k]!=0)
					f[k]/=c[k];
			}
		}
	}
	int mask=(1<<n)-1;
	for(int i=0;i<n;i++)
	{
		printf("%lf ",f[mask-(1<<i)]);
	}
	printf("\n");
	return 0;
}


#include <iostream>

using namespace std;

double g[50][50];
double f[50][50];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			scanf("%lf",&g[i][j]);
	}
	for(int i=0;i<n;i++)
	{
		double ret=1;
		for(int j=0;j<n;j++)
		{
			if(i!=j)
				ret*=g[i][j];
		}
		printf("%lf ",ret);
	}
	printf("\n");
	return 0;
}


#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<queue>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<iostream>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<cstring>
#include<cstdio>
#include<ctime>
#include<climits>
#include<complex>
using namespace std;

double pos[1 << 18];
double win[18][18];

int Cout1Num(int n)
{
    int x = 0;
    while(n){
        x++;
        n = n & (n - 1);
    }
    return x;
}

int main()
{
    int n;
    while (scanf("%d", &n) != EOF) {
        int i, j, k;
        for (i = 0; i < n; ++i) {
            for (j = 0; j < n; ++j) {
                scanf("%lf", &win[i][j]);
            }
        }
        memset(pos, 0, sizeof(pos));
        pos[(1 << n) - 1] = 1.0;

        for (k = (1 << n) - 1; k > 0; --k) {
            int c = Cout1Num(k);
            int sum = c * (c - 1) / 2;

            if (c == 1) {
                continue;
            }

            for (i = 0; i < n; ++i) {
                if ((k & (1 << i)) == 0) {
                    continue;
                }
                for (j = i + 1; j < n; ++j) {
                    if ((k & (1 << j)) == 0) {
                        continue;
                    }
                    pos[k ^ (1 << j)] += pos[k] * win[i][j] / sum;
                    pos[k ^ (1 << i)] += pos[k] * win[j][i] / sum;
                }
            }
        }

        for (i = 0; i < n; ++i) {
            if(i)
                printf(" ");
            printf("%lf", pos[1 << i]);
        }
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>

#define forn(i,n) for (int i=0;i<n;i++)
#define ford(i,n) for (int i=n-1;i>=0;i--)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pi 3.1415926535897932
#define ll long long

using namespace std;

double d[1000000];
double a[20][20];

int main(){
    //freopen ("input.txt","rt",stdin);
    //freopen ("output.txt","wt",stdout);
    int n;
    cin >> n;
    d[0]=1;
    forn(i,n)
        forn(j,n)
            cin >> a[i][j];
    double kol=0;
    for (int i=1;i<(1 << n)-1;i++){
        forn(j,n)
            if ((i & (1 << j))!=0) kol++;
        kol=n-kol+1;
        forn(j,n)
            forn(z,n){
                if (j==z) continue;
                if (((1 << j) & i)!=0 && ((1 << z) & i)==0)
                    d[i]+=d[i ^ (1 << j)]*a[z][j];
        }
        d[i]=d[i]/(kol*(kol-1));
        d[i]*=2;
        kol=0;
    }
    forn(i,n)
        printf ("%0.6f ", d[((1 << n)-1) ^ (1 << i)]);
    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <set>
#include <string>
#include <time.h>
#include <vector>

#define nextLine() {for(int c=getchar(); c!='\n' && c!=EOF; c=getchar());}
#define sqr(a) ((a)*(a))
#define has(mask,i) (((mask) & (1<<(i))) == 0 ? false : true)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

#define TASK "file"

using namespace std;

#define pii pair<int,int>
#define mp(x, y) make_pair(x, y)
#define pb(_o_) push_back(_o_)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double ldb;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<int> vb;
typedef vector<vi> vvb;
typedef list<int> li;
typedef multiset<int>::iterator siit;

const int inf = (1 << 30) - 1;
const ldb eps = 1e-9;
const ldb pi = fabs(atan2(0.0, -1.0));

#ifndef ONLINE_JUDGE
#define parr(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";puts("");}puts("");
#else
#define parr(a,n,m) for(int i=0;i<2;i++)i++;
#endif

void ML()
{
    int *ass;
    for (;;)
    {
        ass = new int[2500000];
        for (int i = 0; i < 2500000; i++)
            ass[i] = rand();
    }
}

int n;
double a[20][20];

struct node
{
    double a[18];
    node()
    {
        for (int i = 0; i < 18; i++)
            a[i] = 0;
    }
    node(const int v)
    {
        for (int i = 0; i < 18; i++)
            if (v == i)
                a[i] = 1;
            else
                a[i] = 0;
    }
};

node ans;

void LoAd()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
}

const int SZ = 262244;
bool was[SZ];
node sv[SZ];

int pack(int *a)
{
    int res = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        res *= 2;
        res += a[i];
    }
    return res;
}

node rec(const int v)
{
    if (was[v])
        return sv[v];

    int up[18];
    memset(up, 0, sizeof(up));

    {
        int tmp = v;
        for (int i = 0; tmp != 0; i++)
        {
            up[i] = tmp % 2;
            tmp /= 2;
        }

        int cct = 0;
        int ind = -1;
        for (int i = 0; i < n; i++)
        {
            if (up[i] == 0)
            {
                cct++;
                ind = i;
            }
        }
        if (cct == 1)
        {
            node res(ind);
            was[v] = true;
            return sv[v] = res;
        }
    }

    node res;
    int cnt = 0;

    for (int i = 0; i < n; i++)
    {
        if (1 == up[i])
            continue;
        for (int j = i + 1; j < n; j++)
        {
            if (1 == up[j])
                continue;
            cnt++;
            up[i] = 1;
            node r1 = rec(pack(up));
            for (int k = 0; k < n; k++)
                r1.a[k] *= a[j][i];
            up[i] = 0;

            up[j] = 1;
            node r2 = rec(pack(up));
            for (int k = 0; k < n; k++)
                r2.a[k] *= a[i][j];
            up[j] = 0;

            for (int k = 0; k < n; k++)
            {
                res.a[k] += r1.a[k];
                res.a[k] += r2.a[k];
            }
        }
    }
    for (int k = 0; k < n; k++)
        res.a[k] /= cnt;

    was[v] = true;
    return sv[v] = res;
}

void SoLvE()
{
    ans = rec(0);
    for (int i = 0; i < n; i++)
        printf("%0.7f ", ans.a[i]);
}

int main()
{
    srand( (int) time(NULL));
#ifndef ONLINE_JUDGE
    freopen(TASK".in","r",stdin);   freopen(TASK".out","w",stdout);
#endif
    LoAd();
    SoLvE();
    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <set>
#include <string>
#include <time.h>
#include <vector>

#define nextLine() {for(int c=getchar(); c!='\n' && c!=EOF; c=getchar());}
#define sqr(a) ((a)*(a))
#define has(mask,i) (((mask) & (1<<(i))) == 0 ? false : true)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

#define TASK "file"

using namespace std;

#define pii pair<int,int>
#define mp(x, y) make_pair(x, y)
#define pb(_o_) push_back(_o_)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double ldb;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<int> vb;
typedef vector<vi> vvb;
typedef list<int> li;
typedef multiset<int>::iterator siit;

const int inf = (1 << 30) - 1;
const ldb eps = 1e-9;
const ldb pi = fabs(atan2(0.0, -1.0));

#ifndef ONLINE_JUDGE
#define parr(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";puts("");}puts("");
#else
#define parr(a,n,m) for(int i=0;i<2;i++)i++;
#endif

void ML()
{
    int *ass;
    for (;;)
    {
        ass = new int[2500000];
        for (int i = 0; i < 2500000; i++)
            ass[i] = rand();
    }
}

int n;
double a[20][20];

struct node
{
    double a[18];
    node()
    {
        for (int i = 0; i < 18; i++)
            a[i] = 0;
    }
    node(const int v)
    {
        for (int i = 0; i < 18; i++)
            if (v == i)
                a[i] = 1;
            else
                a[i] = 0;
    }
};

node ans;

void LoAd()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
}

const int SZ = 1000600;
bool was[SZ];
node sv[SZ];

int pack(int *a)
{
    int res = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        res *= 2;
        res += a[i];
    }
    return res;
}

node rec(const int v)
{
    if (was[v])
        return sv[v];

    int up[18];
    memset(up, 0, sizeof(up));

    {
        int tmp = v;
        for (int i = 0; tmp != 0; i++)
        {
            up[i] = tmp % 2;
            tmp /= 2;
        }

        int cct = 0;
        int ind = -1;
        for (int i = 0; i < n; i++)
        {
            if (up[i] == 0)
            {
                cct++;
                ind = i;
            }
        }
        if (cct == 1)
        {
            node res(ind);
            was[v] = true;
            return sv[v] = res;
        }
    }

    node res;
    int cnt = 0;

    for (int i = 0; i < n; i++)
    {
        if (1 == up[i])
            continue;
        for (int j = i + 1; j < n; j++)
        {
            if (1 == up[j])
                continue;
            cnt++;
            up[i] = 1;
            node r1 = rec(pack(up));
            for (int k = 0; k < n; k++)
                r1.a[k] *= a[j][i];
            up[i] = 0;

            up[j] = 1;
            node r2 = rec(pack(up));
            for (int k = 0; k < n; k++)
                r2.a[k] *= a[i][j];
            up[j] = 0;

            for (int k = 0; k < n; k++)
            {
                res.a[k] += r1.a[k];
                res.a[k] += r2.a[k];
            }
        }
    }
    for (int k = 0; k < n; k++)
        res.a[k] /= cnt;

    was[v] = true;
    return sv[v] = res;
}

void SoLvE()
{
    ans = rec(0);
    for (int i = 0; i < n; i++)
        printf("%0.7f ", ans.a[i]);
}

int main()
{
    srand( (int) time(NULL));
#ifndef ONLINE_JUDGE
    freopen(TASK".in","r",stdin);   freopen(TASK".out","w",stdout);
#endif
    LoAd();
    SoLvE();
    return 0;
}


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

double dp[1<<18];

int main()
{
    int n;
    cin >> n;
    int mask = 1<<n;
    mask--;
    double a[18][18];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    for (int i = mask; i >= 0; i--)
        dp[i] = 0.0;
    dp[mask] = 1.0;
    for (int i = mask; i >= 0; i--)
    {
        int cnt = 0;
        int k = i;
        while (k != 0)
            cnt++, k &= k & (k - 1);
        for (int i1 = 0; i1 < n; i1++)
            if ((i & (1 << i1)) != 0)
                for (int j = 0; j < n; j++)
                    if ((i & (1 << j)) != 0)
                        dp[i - (1<<i1)] += dp[i] * a[j][i1] * 2 / (cnt) / (cnt - 1);
    }
    for (int i = 0; i < n; i++)
        cout << fixed << dp[1 << i] << " ";
    return 0;
}


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

double dp[1<<18];

int main()
{
    int n;
    cin >> n;
    int mask = 1<<n;
    mask--;
    double a[18][18];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    for (int i = mask; i >= 0; i--)
        dp[i] = 0.0;
    dp[mask] = 1.0;
    for (int i = mask; i >= 0; i--)
    {
        for (int i1 = 0; i1 < n; i1++)
            if (i & (1 << i1) != 0)
                for (int j = i1 + 1; j < n; j++)
                    if (i & (1 << j) != 0)
                    {
                        dp[i - (1<<i1)] += dp[i] * a[j][i1] * (2.0 / (__popcnt(i) - 1.0) / __popcnt(i));
                        dp[i - (1<<j)] += dp[i] * a[i1][j] * (2.0 / (__popcnt(i) - 1.0) / __popcnt(i));
                    }
    }
    for (int i = 0; i < n; i++)
        cout << fixed << dp[1 << i] << " ";
    return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <hash_map>
#include <functional>
#include <sstream>
#include <stack>
#include <iterator>
using namespace std;

const double eps = 1e-10;

int count(int number, int n)
{
	int result = 0;
	for (int i = 0; i < n; i++) {
		if ((number & (1 << i)) == 0) {
			result++;
		}
	}
	return result;
}

double dp[1 << 18];

int main()
{
	int n = 0;
	cin >> n;
	double p[18][18];
	memset(p, 0, sizeof(p));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> p[i][j];
		}
	}
	memset(dp, 0, sizeof(p));
	dp[0] = 1;
	int cur_m = (1 << n) - 1;
	for (int i = 0; i < cur_m; i++) {
		int c = count(i, n);
		if (c <= 1) {
			continue;
		}
		double total = c * (c - 1) / 2;
		for (int j = 0; j < n; j++) {
			if ((i & (1 << j)) > 0) {
				continue;
			}
			for (int k = j + 1; k < n; k++) {
				if ((i & (1 << k)) > 0) {
					continue;
				}
				// ������� ������
				dp[i | (1 << k)] += dp[i] * p[j][k] / total;
				// ������� ������
				dp[i | (1 << j)] += dp[i] * (1-p[j][k]) / total;
			}
		}
	}
	cout.setf(ios::fixed);
	for (int i = 0; i < n; i++) {
		cout << dp[cur_m & ~(1 << i)] << " ";
	}
	return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;

double alive[18][1<<18];
bool was[18][1<<18];

double G[18][18];
int n;

double DFS(int ver, int mask){
	if (was[ver][mask]){
		return alive[ver][mask];
	}
	double ret = 0;
	int q = 0;
	for (int i=0; i<n; i++){
		if (! (mask & (1 << i))){
			q++;
		}
	}

	if (q == 1){
		return 1;
	}

	was[ver][mask] = 1;
	for (int i=0; i<n; i++){
		if (! (mask & (1 << i))){
			for (int j=i+1; j<n; j++){
				if (! (mask & (1 << j))){
					if (i != ver){
						ret += G[j][i] * DFS(ver, mask | (1 << i));
					}

					if (j != ver){
						ret += G[i][j] * DFS(ver, mask | (1 << j));
					}
				}
			}
		}
	}
	ret /= q*(q-1)/2;
	return alive[ver][mask] = ret;
}

int main(){
	memset(was, 0, sizeof was);
	cin >> n;
	for (int i=0; i<n; i++){
		for (int j=0; j<n; j++){
			cin >> G[i][j];
		}
	}

	for (int i=0; i<n; i++){
		cout << fixed << setprecision(10) <<  DFS(i, 0) << " ";
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <list>
#include <cmath>
#include <cctype>
using namespace std;
#define max(a,b) ((a)>(b)?(a):(b))
int n;
double mas[20][20];
double dp[(1<<19)];
bool was[(1<<19)];
bool getbit(int n, int bit){
    return (n&(1<<bit))!=0;
}
void solvedp(int pos){
    if (was[pos]) return;
    was[pos]=true;
    if (pos==(1<<n)-1){
        dp[pos]=1;
    }
    else{
        dp[pos]=0;
        int nbit=0;
        for(int i=0; i<n;i++)
            if (getbit(pos, i))
                nbit++;
        for(int i=0;i<n;i++)
            if (!getbit(pos,i)){
                solvedp(pos | (1<<i));
                for(int j=0;j<n;j++)
                    if (getbit(pos,j)){

                        dp[pos]+=mas[j][i]*dp[pos | (1<<i)];
                    }
            }
        dp[pos]*=1.0/((nbit+1)*nbit/2);
    }
}
void init(){
    scanf("%d", &n);
    for(int i=0; i<n;i++)
        for(int j=0;j<n;j++){
            scanf("%lf", &mas[i][j]);
        }
}
void solve(){
    for(int i=0; i<n;i++){
        solvedp(1<<i);
        printf("%.8lf", dp[1<<i]);
        if (i<n-1)
            printf(" ");
    }
}
int main()
{
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    init();
    solve();
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#pragma comment(linker, "/STACK:16777216")
using namespace std;

#define bit(n) (1<<(n))
#define inf 1000000000
#define eps 1e-9
#define pi 3.1415926535897932385
#define pb push_back
#define sz size()
#define mp make_pair
#define cl clear()
#define all(a) a.begin(),a.end()
#define fill(ar,val) memset(ar,val,sizeof ar)
#define MIN(a,b) if(a>(b)) a=(b)
#define MAX(a,b) if(a<(b)) a=(b)
#define sqr(x) ((x)*(x))
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

typedef vector<int> VI;
typedef pair<int,int> PII;
//typedef long long LL;

#define N 18
double a[N][N];
double p[1<<N];

int main()
{
    int n;
    while(scanf("%d",&n)>0)
    {
        int i,j;
        for(i=0;i<n;i++)
            for(j=0;j<n;j++) scanf("%lf",&a[i][j]);
        fill(p,0);
        p[bit(n)-1]=1;
        for(int mask=bit(n)-1;mask>0;mask--)
        {
            int cnt=0;
            for(i=0;i<n;i++) if(mask & bit(i)) cnt++;
            double c2n=cnt*(cnt-1)/2.;
            for(i=0;i<n;i++) if(mask & bit(i))
                for(j=0;j<n;j++) if(mask & bit(j))
                    if(i!=j)
                        p[mask-bit(i)]+=p[mask]*a[j][i]/c2n;
        };
        for(i=0;i<n;i++)
            printf("%.7lf%c",p[1<<i],i<n-1?' ':'\n');
    }
    return 0;
}


#include<iostream>
#include<cstring>
using namespace std;

const int maxn=18;
double a[maxn][maxn];
double f[1<<maxn];
int n;

void init()
  {
   scanf("%d",&n);
   for (int i=0;i<n;i++)
     for (int j=0;j<n;j++)
       scanf("%lf",&a[i][j]);
  }

void solve()
  {
   memset(f,0,sizeof(f));
   f[(1<<n)-1]=1;
   for (int s=(1<<n)-2;s>0;s--)
     for (int i=0;i<n;i++)
       if ((s & (1<<i)))
         for (int j=0;j<n;j++)
           if (!(s & (1<<j)))
             {
              int k=0;
              for (int l=0;l<n;l++) if ((s | (1<<j)) & (1<<l)) k++;
              f[s]+=f[s | (1<<j)]*a[i][j]/(k*(k-1)/2);
             }
  }

void print()
  {
   for (int i=0;i<n;i++)
     {
      printf("%.6lf",f[1<<i]);
      if (i!=n-1) printf(" ");
     }
   printf("\n");
  }

int main()
  {
   //freopen("fish.in","r",stdin);
   //freopen("fish.out","w",stdout);
   init();
   solve();
   print();
   return 0;
  }


#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;

const int maxn=18;
double f[maxn][1<<maxn];
double a[maxn][maxn];
int n;

void init()
  {
   scanf("%d",&n);
   for (int i=0;i<n;i++)
     for (int j=0;j<n;j++)
       scanf("%lf",&a[i][j]);
  }

void solve()
  {
   for (int i=0;i<n;i++) f[i][1<<i]=1;
   for (int st=1;st<1<<n;st++)
     for (int i=0;i<n;i++)
       if ((st & (1<<i))>0 && f[i][st]==0)
         {
          for (int s=1;s<st;s++)
            if ((st & s)==s && !(s & (1<<i)))
              for (int j=0;j<n;j++)
                if ((s & (1<<j))>0)
                  f[i][st]=max(f[i][st],f[j][s]*f[i][st-s]*a[i][j]);
         }
  }

int main()
  {
   //freopen("fish.in","r",stdin);
   //freopen("fish.out","w",stdout);
   init();
   solve();
   for (int i=0;i<n;i++)
     {
      printf("%.6lf",f[i][(1<<n)-1]);
      if (i!=n-1) printf(" ");
     }
   printf("\n");
   return 0;
  }


#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cctype>
using namespace std;

typedef long long int64;
const int maxn=50;
int n,m,k,o,t,l,ll,ans;
int x[2];
char s[maxn];
string st,sm;
bool flag;

int main()
  {
   //freopen("day.in","r",stdin);
   //freopen("day.out","w",stdout);
   scanf("%d\n",&n);
   l=100000;ans=0;ll=0;
   for (int i=0;i<n;i++)
     {
      gets(s);st=s;
      x[0]=x[1]=o=t=0;
      sm="";flag=false;
      for (int j=0;j<st.length();j++)
        {
         if (st[j]==':') o++;
         if (o<2 && '0'<=st[j] && st[j]<='9') x[o]=x[o]*10+st[j]-'0';
         if (st[j]=='p') t=720;
         if (st[j]=='a' || st[j]=='p') o++;
        }
      if (x[0]==12) x[0]=0;
      t+=(x[0]-1)*60+x[1];
      if (l>t || l==t && ll==10) {flag=true;ans++;}
      if (flag) ll=1;
      if (!flag && l==t) ll++;
      if (!flag && l<t) ll=1;
      l=t;
      //cout<<l<<endl;
     }
   printf("%d\n",ans);
   return 0;
  }


#include<iostream>
#include<cstring>
#include<ctime>
using namespace std;

const int maxn=18;
double a[maxn][maxn];
double f[1<<maxn];
int vis[1<<maxn];
int n,t,tt;
double b,e;

void init()
  {
   scanf("%d",&n);
   for (int i=0;i<n;i++)
     for (int j=0;j<n;j++)
       scanf("%lf",&a[i][j]);
  }

void solve()
  {
   memset(f,0,sizeof(f));
   f[(1<<n)-1]=1;
   for (int s=(1<<n)-2;s>0;s--)
     for (int i=0;i<n;i++)
       if ((s & (1<<i)))
         for (int j=0;j<n;j++)
           if (!(s & (1<<j)))
             {
              int k=vis[s|(1<<j)];
              f[s]+=f[s | (1<<j)]*a[i][j]/(k*(k-1)/2);
             }
  }

void print()
  {
   for (int i=0;i<n;i++)
     {
      printf("%.6lf",f[1<<i]);
      if (i!=n-1) printf(" ");
     }
   printf("\n");
  }

int main()
  {
   //freopen("fish.in","r",stdin);
   //freopen("fish.out","w",stdout);
   //b=clock()/CLOCKS_PER_SEC;
   for (int i=0;i<1<<maxn;i++)
     for (int j=0;j<maxn;j++)
       if (i & (1<<j))
         vis[i]++;
   //scanf("%d",&t);
  // for (tt=0;tt<t;tt++)
     {
      init();
      solve();
      print();
     }
   //e=clock()/CLOCKS_PER_SEC;
   //printf("%.6lf\n",e-b);
   return 0;
  }


#include <iostream>
#include <fstream>
#include <cstdio>
#include <iomanip>
#include <algorithm>

using namespace std;

const int MAXN = 18;
const int MAX = 1 << 18;
const double EPS = 0.00000001;

double p[MAXN][MAXN];

double dp[MAX];

int n;

double find(int f) {
	if (dp[f] < 0) {
		double ans = 0;
		int k = 0;
		for (int i = 0; i < n; i++) {
			if (((f & (1 << i))) != 0) {
				k++;
			}
		}
		double pp = 2.0 / ((k + 1) * k);
		for (int i = 0; i < n; i++) {
			if ((f & (1 << i)) == 0) {
				for (int j = 0; j < n; j++) {
					if (((f & (1 << j))) != 0) {
						ans += find(f | (1 << i)) * p[j][i] * pp;
					}
				}
			}
		}
		dp[f] = ans;
	}
	return dp[f];
}

int main() {
#ifdef _DEBUG
	freopen("c.in", "r", stdin);
	freopen("c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);

	fill(dp, dp + MAX, -1);

	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> p[i][j];
		}
	}

	dp[(1 << n) - 1] = 1.0;

	for (int i = 0; i < n; i++) {
		cout << find(1 << i) << ' ';
	}

	return 0;
}


//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <cmath>
#include <algorithm>

using namespace std;

#define forn(i,n) for(int i = 0; i < (n); ++i)
#define forr(i,n) for(int i = (n)-1; i >= 0; i--)
#define forn1(i,n) for(int i = 1; i <= (n); ++i)
#define forr1(i,n) for(int i = (n); i >= 1; i--)
#define forit(it,x) for(it = (x).begin(); it != (x).end(); ++it)

template <typename T> T gcd(T a, T b){return b? gcd(b, a%b) : a;}
#define fr first
#define sc second
#define sz size()
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<int64> vi64;
typedef vector<string> vs;
typedef vector< vi > vvi;
typedef vector< vc > vvc;
typedef vector<bool> vb;
typedef vector< pii > vpii;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("ReadMe.txt","r",stdin);
#endif

	int n; cin >> n;

	vector< vector<double> > a(n,vector<double>(n));
	forn(i,n)
		forn(j,n)
	{
		cin >> a[i][j];
	}

	vd f(1 << n);
	f[(1 << n) - 1] = 1;
	for(int mask = (1 << n) - 1; mask > 0; --mask)
	{
		int s = 0;
		forn(i,n)
		{
			if(mask & (1 << i) )
				s++;
		}
		forn(i,n)
		{
			if(mask & (1 << i) )
			forn(j,n)
			{
				if(mask & (1 << j) && i != j)
				{
					f[mask - (1 << j)] += f[mask]*a[i][j]*2/((double)s*(s-1));
				}
			}
		}
	}

	forn(i,n)
	{
		printf("%.12f\n",f[(1 << i)]);
	}

	return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
const double eps = 1e-8;

int n;
bool used[1<<18];
double f[1<<18], a[18][18];

void dp(int s);

int main()
{
	cin>>n;
	for(int i=0; i<(1<<n); i++)
		f[i] = -1;
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin>>a[i][j];
	f[(1<<n)-1] = 1.0;
	dp((1<<n)-1);
	for(int i=0; i<n; i++)
	{
		if( i )
			printf(" ");
		printf("%.6f", f[1<<i]);
	}
	printf("\n");

	return 0;
}

void dp(int s)
{
	if( used[s] )
		return;
	for(int i=0; i<n; i++)
		if( (s&(1<<i)) )
			for(int j=i+1; j<n; j++)
				if( (s&(1<<j)) )
				{
					int t = s^(1<<j);  // j is dead.
					f[t] = f[s]*a[i][j];
					dp(t);
					t = s^(1<<i);      // i is dead.
					f[t] = f[s]*a[j][i];
					dp(t);
				}

	used[s] = true;
}


#include <iostream>
#include <cmath>
using namespace std;

double f[1<<18], a[18][18];

void dp(int s);

int main()
{
	int n, cnt;

	cin>>n;
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin>>a[i][j];

	f[(1<<n)-1] = 1.0;
	for(int s=(1<<n)-1; s>=0; s--)
	{
		cnt = 0;
		for(int i=0; i<n; i++)
			if( s&(1<<i) )
				cnt++;
		cnt = cnt*(cnt-1)/2;
		for(int i=0; i<n; i++)
			if( (s&(1<<i)) )
				for(int j=i+1; j<n; j++)
					if( (s&(1<<j)) )
					{
						int t = s^(1<<j);  // j is dead.
						f[t] += f[s]*a[i][j]/cnt;
						t = s^(1<<i);      // i is dead.
						f[t] += f[s]*a[j][i]/cnt;
					}
	}

	for(int i=0; i<n; i++)
	{
		if( i )
			printf(" ");
		printf("%.6f", f[1<<i]);
	}
	printf("\n");

	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    for (int i=0;i<n;i++)
    {
        cin>>s;
        if (s.length>10)
        cout<<s[0]+s[s.length()-2]+s[s.length-1]<<endl;
        else
        cout<<s<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    for (int i=0;i<n;i++)
    {
        cin>>s;
        if (s.length()>10){
        long double w=s.length();
        string a=to_string(w);
        cout<<s[0]+a+s[s.length-1]<<endl;
        }
        else
        cout<<s<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    for (int i=0;i<n;i++)
    {
        cin>>s;
        if (s.length()>10)
        string a=to_string(s.length());
        cout<<s[0]+a+s[s.length-1]<<endl;
        else
        cout<<s<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    for (int i=0;i<n;i++)
    {
         cin>>s;
        if (s>10)
        cout<<s[0]+s[s.length()-2]+s[s.length-1]<<endl;
        else
        cout<<s<<endl;
    }
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    for (int i=0;i<n;i++)
    {
        cin>>s;
        if (s.length()>10){
        long double w=s.length()-2;
        string a=to_string(w);
        cout<<s[0]+a+s[s.length()-1]<<endl;
        }
        else
        cout<<s<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    for (int i=0;i<n;i++)
    {
         cin>>s;
        if (s>10)
        cout<<s[0]+s[s.length()-2]+s[s.length-1]<<endl;
        else
        cout<<s<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if (s>10)
        cout<<s(0)+s(s.length()-2)+s(s.length-1);
        else
        cout<<s;
    }
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin>>n;

    for (int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if (s[s.length()]>10)
        cout<<s[0]+s[s.length()-2]+s[s.length-1]<<endl;
        else
        cout<<s<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if (s>10)
        cout<<s(0)+s(s.length()-2)+s(s.length-1);
        else
        cout<<s;
    }
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    for (int i=0;i<n;i++)
    {
        cin>>s;
        if (s[s.length]>10)
        cout<<s[0]+s[s.length()-2]+s[s.length-1]<<endl;
        else
        cout<<s<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    for (int i=0;i<n;i++)
    {
        cin>>s;
        if (s.length()>10){
        long double w=s.length();
        string a=to_string(w);
        cout<<s[0]+a+s[s.length()-1]<<endl;
        }
        else
        cout<<s<<endl;
    }
    return 0;
}


//
//  main.c
//  code forces
//
//  Created by Yasna Katebzadeh on 12/29/1396 AP.
//  Copyright © 1396 Yasna Katebzadeh. All rights reserved.
//

#include  <stdio.h>

#include <string.h>
int main()
{
    char Str[100];

    int n;
    unsigned long length;

    scanf("%d",&n);

    for(int i = 0 ; i < n ; i++)
    {
        scanf("%s",Str);
        length = strlen(Str);

        if(length > 10)
        {
            printf("%c%lu%c\n",Str[0], length - 2 ,Str[length - 1]);
        }

        else
        {
            puts(Str);
        }

    }

    return 0;
}


//
//  main.c
//  code forces
//
//  Created by Yasna Katebzadeh on 12/29/1396 AP.
//  Copyright © 1396 Yasna Katebzadeh. All rights reserved.
//

#include  <stdio.h>
#include <math.h>
#include <string.h>
int main(){
    int n;
    scanf("%d",&n);

    char f[100];
    while( n--){
        scanf("%s",f);
    unsigned long  t ;
    t=strlen(f);
    if ( t <= 10){
        printf("%s\n",f);

    }
    else
    {printf("%c%lu%c\n",f[0],t-2,f[t-1]);}
        }

}


//
//  main.c
//  code forces
//
//  Created by Yasna Katebzadeh on 12/29/1396 AP.
//  Copyright © 1396 Yasna Katebzadeh. All rights reserved.
//

#include  <stdio.h>
#include <math.h>
#include <string.h>
int main(){
    int n;
    scanf("%d",&n);

    char f[100];
    while( n > 0){
        scanf("%s",f);
    unsigned long  t ;
    t=strlen(f);
    if ( t <= 10){
        printf("%s",f);

    }
    else
    {printf("%c%lu%c",f[0],t-2,f[t-1]);}
        n --;}

}


//
//  main.c
//  code forces
//
//  Created by Yasna Katebzadeh on 12/29/1396 AP.
//  Copyright © 1396 Yasna Katebzadeh. All rights reserved.
//

#include  <stdio.h>

#include <string.h>
int main()
{
    char Str[100];

    int n;
    unsigned long length;

    scanf("%d",&n);
    if ( n > 100 || n < 1)return 0;

    for(int i = 0 ; i < n ; i++)
    {
        scanf("%s",Str);
        length = strlen(Str);
        if (length > 100 )return 0;

        if(length > 10)
        {
            printf("%c%lu%c\n",Str[0], length - 2 ,Str[length - 1]);
        }

        else
        {
            puts(Str);
        }

    }

    return 0;
}


//
//  main.c
//  code forces
//
//  Created by Yasna Katebzadeh on 12/29/1396 AP.
//  Copyright © 1396 Yasna Katebzadeh. All rights reserved.
//

#include  <stdio.h>

#include <string.h>
int main()
{
    char Str[100];

    int n;
    unsigned long length;

    scanf("%d",&n);
    if ( n > 100 || n < 1)return 0;

    for(int i = 0 ; i < n ; i++)
    {
        scanf("%s",Str);
        length = strlen(Str);

        if(length > 10)
        {
            printf("%c%lu%c\n",Str[0], length - 2 ,Str[length - 1]);
        }

        else
        {
            puts(Str);
        }

    }

    return 0;
}


//
//  main.c
//  code forces
//
//  Created by Yasna Katebzadeh on 12/29/1396 AP.
//  Copyright © 1396 Yasna Katebzadeh. All rights reserved.
//

#include  <stdio.h>
#include <math.h>
#include <string.h>
int main(){
    int n;
    scanf("%d",&n);
    while( n > 0){

    char f[100];
    scanf("%s",f);
    unsigned long  t ;
    t=strlen(f);
    if ( t <= 10){
        printf("%s",f);

    }
    else
    {printf("%c%lu%c",f[0],t-2,f[t-1]);}
        n --;}

}


//
//  main.c
//  code forces
//
//  Created by Yasna Katebzadeh on 12/29/1396 AP.
//  Copyright © 1396 Yasna Katebzadeh. All rights reserved.
//

#include  <stdio.h>

#include <string.h>
int main()
{
    char Str[100];

    int n,length;

    scanf("%d",&n);

    for(int i = 0 ; i < n ; i++)
    {
        scanf("%s",Str);
        length = strlen(Str);

        if(length > 10)
        {
            printf("%c%d%c\n",Str[0], length - 2 ,Str[length - 1]);
        }

        else
        {
            puts(Str);
        }

    }

    return 0;
}


//
//  main.c
//  code forces
//
//  Created by Yasna Katebzadeh on 12/29/1396 AP.
//  Copyright © 1396 Yasna Katebzadeh. All rights reserved.
//

#include  <stdio.h>

#include <string.h>
int main()
{
    char Str[101];

    int n;
    unsigned long length;

    scanf("%d",&n);
    if ( n > 100 || n < 1)return 0;

    for(int i = 0 ; i < n ; i++)
    {
        scanf("%s",Str);
        length = strlen(Str);

        if(length > 10)
        {
            printf("%c%lu%c\n",Str[0], length - 2 ,Str[length - 1]);
        }

        else
        {
            puts(Str);
        }

    }

    return 0;
}


//
//  main.c
//  code forces
//
//  Created by Yasna Katebzadeh on 12/29/1396 AP.
//  Copyright © 1396 Yasna Katebzadeh. All rights reserved.
//

#include  <stdio.h>
#include <math.h>
#include <string.h>
int main(){
    int n,t;

    scanf("%d",&n);

    char f[100];
    while( n--){
        scanf("%s",f);

    t=strlen(f);
    if ( t <= 10){
        printf("%s\n",f);

    }
    else
    {printf("%c%d%c\n",f[0],t-2,f[t-1]);}
        }

}


//
//  main.c
//  code forces
//
//  Created by Yasna Katebzadeh on 12/29/1396 AP.
//  Copyright © 1396 Yasna Katebzadeh. All rights reserved.
//

#include  <stdio.h>
#include <math.h>
#include <string.h>
int main(){
    int n,t;

    scanf("%d",&n);

    char f[100];
    while( n--){
        scanf("%s",f);

    t=strlen(f);
    if ( t <= 10){
        printf("%s\n",f);

    }
    else
    {printf("%c%lu%c\n",f[0],t-2,f[t-1]);}
        }

}


#include<iostream>
#include<string>

using namespace std ;
int main()
{
int n ;
int i=0;
for (int i = 1 ; x<= n; x++) {
string w ;
cin>>w;
while (w[i]!=0)
{
i++;
}
if (i>=10) { cout<<w[0]<<i-2<<w[i-1]<<endl; } else { cout<<w<<endl; }
}
return 0;
}


#include<iostream>
#include<string>

using namespace std;
int main()
{
	int n, x;
	cin >> n;
	int i = 0;
	string w;
	for (x = 1; x <= n; x ++)
	{
		cin >> w;

		if (w.length()  > 10)
		{
			cout << w[0] << w.length()-2 << w[w.length() - 1] << endl;
		}
		else
		{
			cout << w << endl;
		}
	}
	return 0;
}


#include<iostream>
#include<string>

using namespace std ;
int main()
{
int n,x ;
cin>>n;
int i=0;
string w ;
for (x = 1 ; x<= n; x=x+1 ) {
cin>>w;
while (w[i]!=0)
{
i++;
}
if (i>=10) { cout<<w[0]<<i-2<<w[i-1]<<endl; } else { cout<<w<<endl; }
}
return 0;
}


#include<iostream>
#include<string>

using namespace std ;
int main()
{
int n
int i=0;
for (int i = 1 ; x<= n; x++) {
string w ;
cin>>w;
while (w[i]!=0)
{
i++;
}
if (i>=10) { cout<<w[0]<<i-2<<w[i-1]; } else { cout<<w; }
}
return 0;
}


#include<bits/stdc++.h>
using namespace std ;
int main()
{
int i=0;
string n ;
cin>>n;
while (n[i]!=0)
{
i++;
}
if (i>=10) { cout<<n[0]<<i-2<<n[i-1]; } else { cout<<n; }
return 0;
}


#include<iostream>
#include<string>

using namespace std ;
int main()
{
int i=0;
string n ;
cin>>n;
while (n[i]!=0)
{
i++;
}
if (i>=10 && n>1 && n<1) { cout<<n[0]<<i-2<<n[i-1]; } else { cout<<n; }
return 0;
}


#include<iostream>
#include<string>

using namespace std ;
int main()
{
int n,x ;
cin>>n;
int i=0;
string w ;
for For (int x = 0 ; x<n ; x++) {
cin>>w;
while (w[i]!=0)
{
i++;
}
if (i>=10) { cout<<w[0]<<i-2<<w[i-1]<<endl; } else { cout<<w<<endl; }
}
return 0;
}


#include<iostream>
#include<string>

using namespace std ;
int main()
{
int i=0;
string n ;
cin>>n;
if (n>1 && n<1) { system ("PAUSE"); }
while (n[i]!=0)
{
i++;
}
if (i>=10) { cout<<n[0]<<i-2<<n[i-1]; } else { cout<<n; }
return 0;
}


#include<iostream>
#include<string>

using namespace std ;
int main()
{
int n,x ;
cin>>n;
int i=0;
string w ;
for (x = 1 ; x<= n; x=x+1 ) {
cin>>w;
while (w[i]!=0)
{
i++;
}
if (i>=10) { cout<<w[0]<<i-2<<w[i-1]; } else { cout<<w; }
}
return 0;
}


#include<iostream>
#include<string>

using namespace std ;
int main()
{
int n,x ;
cin>>n;
int i=0;
string w ;
for (x = 0 ; x<n; x=x+1 ) {
cin>>w;
while (w[i]!=0)
{
i++;
}
if (i>=10) { cout<<w[0]<<i-2<<w[i-1]<<endl; } else { cout<<w<<endl; }
}
return 0;
}


#include<iostream>
#include<string>

using namespace std ;
int main()
{
int i=0;
string n ;
cin>>n;
while (n[i]!=0)
{
i++;
}
if (i>=10) { cout<<n[0]<<i-2<<n[i-1]; } else { cout<<n; }
return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int m;
	cin >> m;
	for (int p = 0; (p < m); p++)
	{
		string me;
		cin >> me;
		int x = me.length();

		if (me.length() > 4)

			cout << me.at(0) << x-2 << me.at(x--);
		else cout << me;

	}
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int m;
	string me;
	cin >> m;
	for (int p = 0; (p < m); p++)
	{

		cin >> me;
		if (me.length > 4)

			cout << me.at(0) << me.length() - 2 << me.at(me.length - 1) << endl;
		else cout << me << endl;

	}

	system ("pause")
		return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int m;
	cin >> m;
	for (m; m != 0; m--)
	{
		string me;
		cin >> me;
		int x = me.length();

		if (me.length() > 3)

			cout << me.at(0) << x-- << me.at(x);
		else cout << me;

	}
}


#include<iostream>
#include<string>
using namespace std;

int main()
{
	int m;
	string me;
	cin >> m;
	for (int p = 0; (p < m); p++)
	{

		cin >> me;
		if (me.length > 4)

			cout << me.at(0) << me.length() - 2 << me.at(me.length - 1) << endl;
		else cout << me << endl;

	}

	system("pause");
		return 0;
}


#include<iostream>
#include<string>
using namespace std;

int main()
{
	int m;
	string me;
	cin >> m;
	for (int p = 0; (p < m); p++)
	{

		cin >> me;
		if (me.length() > 4)

			cout << me.at(0) << me.length() - 2 << me.at(me.length() - 1) << endl;
		else cout << me << endl;

	}

		return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int m;
	cin >> m;
	while (m != 0)
	{
		string me;
		cin >> me;
		int x = me.length();

		if (me.length() > 3)

			cout << me.at(0) << x-- << me.at(x);
		else cout << me;
		m--;
	}
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	string me;
	int x;
	cin >> me;
	x = me.length();

	if (me.length() > 3)
		cout << me.at(0) << x-- << me.at(x);
	else cout << me;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int m;
	string me;
	cin >> m;
	for (int p = 0; (p < m); p++)
	{

		cin >> me;
		if (me.length > 4)

			cout << me.at(0) << me.length() - 2 << me.at(me.length - 1) << endl;
		else cout << me << endl;

	}
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int m;
	cin >> m;
	while (m != 0 )
	{
	  string me;
	  int x;
	  cin >> me;
	  x = me.length();

	  if (me.length() > 3)
		cout << me.at(0) << x-- << me.at(x);
	  else cout << me;
	   m--;
	}
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int m;
	cin >> m;
	for (m, m != 0, m--)
	{
		string me;
		cin >> me;
		int x = me.length();

		if (me.length() > 3)

			cout << me.at(0) << x-- << me.at(x);
		else cout << me;

	}
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int m;
	cin >> m;
	for (int x = 0; x < m; x++)
	{
		string me;
		cin >> me;
		int x = me.length();

		if (me.length() > 3)

			cout << me.at(0) << x-- << me.at(x);
		else cout << me;

	}
}


#include <iostream>
#include <string>
using namespace std;

int main()
{

	cin >> int m;
	while (m != 0 )
	{
	  cin >> string me;
	  int x = me.length();

	  if (me.length() > 3)

		  cout << me.at(0) << x-- << me.at(x);
	  else cout << me;
	   m--;
	}
}


#include<iostream>
#include<string>
using namespace std;

int main()
{
	int m;
	string me;
	cin >> m;
	for (int p = 0; (p < m); p++)
	{

		cin >> me;
		if (me.length > 4)

			cout << me.at(0) << me.length() - 2 << me.at(me.length - 1) << endl;
		else cout << me << endl;

	}

		return 0;
}


#include<iostream>
#include<string>
using namespace std;

int main()
{
	int m;
	string me;
	cin >> m;
	for (int p = 0; (p < m); p++)
	{

		cin >> me;
		if (me.length() > 10)

			cout << me.at(0) << me.length() - 2 << me.at(me.length() - 1) << endl;
		else cout << me << endl;

	}

		return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int m;
	string me;
	cin >> m;
	for (int p = 0; (p < m); p++)
	{

		cin >> me;
		int x = me.length();

		if (me.length > 4)

			cout << me.at(0) << x - 2 << me.at(x--);
		else cout << me;

	}
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int m;
	cin >> m;
	for (int p = 0; (p < m); p++)
	{
		string me;
		cin >> me;
		int x = me.length();

		if (me.length() > 3)

			cout << me.at(0) << x-- << me.at(x);
		else cout << me;

	}
}


// string.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
using namespace std;

int main() {

	string word;
	cin >> word;
	int x = word.length();
	x++;
	cout << word.substr (0, 0) << (x - 2) << word.substr (x, x);
}


#include<iostream>

using namespace std;
int main(){
    int n;
    string a[100];
    cin>>n;

    for(int i = 0; i < n; i ++){
        cin>>a[i];
    }

    for( int i = 0 ; i < n ; i ++){
        int k = a[i].length();
        if(k<12){
            cout<<a[i]<<endl;
        }else{
                cout <<a[i][0]<<(a[i].length() - 2)<< a[i][k-1]<<endl;
        }
    }
    return 0;
}


#include<iostream>

using namespace std;
int main(){
    int n;
    string a[100];
    cin>>n;

    for(int i = 0; i < n; i ++){
        cin>>a[i];
    }

    for( int i = 0 ; i < n ; i ++){
        int k = a[i].length();
        if(k<10){
            cout<<a[i]<<endl;
        }else{
                cout << a[i][0] << a[i].length() - 2 << a[i][k-1] << endl;
        }
    }
}


#include<iostream>
using namespace std;
int main(){
    int n;
    string a[100];
    cin >> n;

    for(int i = 0; i < n; i ++){
        cin>>a[i];
    }

    for( int i = 0 ; i < n ; i ++){
        int k = a[i].length();
        if(k<12){
            cout << a[i]<<endl;
        }else{
                cout << a[i][0] << a[i].length() - 2 << a[i][k-1] << endl;
        }
    }
}


#include<iostream>

using namespace std;
int main(){
    int n;
    string a[100];
    cin >> n;

    for(int i = 0; i < n; i ++){
        cin>>a[i];
    }

    for( int i = 0 ; i < n ; i ++){
        int k = a[i].length();
        if(k<10){
            cout << a[i]<<endl;
        }else{
                cout << a[i][0] << a[i].length() - 2 << a[i][k-1] << endl;
        }
    }
}


#include<iostream>

using namespace std;
int main(){
	int n;
	string a[100];
	cin >> n;

	for(int i = 0; i < n; i ++){
		cin>>a[i];
	}

	for( int i = 0 ; i < n ; i ++){
		int k = a[i].length();
		if(k<10){
			cout << a[i]<<endl;
		}else{
				cout << a[i][0] << a[i].length() - 2 << a[i][k-1] << endl;
		}
	}
}


#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    string a[100];
    cin >> n;

    for(int i = 0; i < n; i ++){
        cin>>a[i];
    }

    for( int i = 0 ; i < n ; i ++){
        int k = a[i].length();
        if(k<=10){
            cout << a[i]<<endl;
        }else{
                cout << a[i][0] << a[i].length() - 2 << a[i][k-1] << endl;
        }
    }
}


#include<iostream>

using namespace std;
int main(){
    int n;
    string a[100];
    cin>>n;

    for(int i = 0; i < n; i ++){
        cin>>a[i];
    }

    for( int i = 0 ; i < n ; i ++){
        int k = a[i].length();
        if(k<10){
            cout<<a[i]<<endl;
        }else{
                cout <<a[i][0]<<(a[i].length() - 2)<< a[i][k-1]<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    string a[100];
    cin >> n;

    for(int i = 0; i < n; i ++){
        cin>>a[i];
    }

    for( int i = 0 ; i < n ; i ++){
        int k = a[i].length();
        if(k<10){
            cout << a[i]<<endl;
        }else{
                cout << a[i][0] << a[i].length() - 2 << a[i][k-1] << endl;
        }
    }
}


#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    string a[100];
    cin>>n;

    for(int i = 0; i < n; i ++){
        cin>>a[i];
    }

    for( int i = 0 ; i < n ; i ++){
        int k = a[i].length();
        if(k<10){
            cout<<a[i]<<endl;
        }else{
                cout <<a[i][0]<<(a[i].length() - 2)<< a[i][k-1]<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	string a[100];
	cin >> n;

	for(int i = 0; i < n; i ++){
		cin>>a[i];
	}

	for( int i = 0 ; i < n ; i ++){
		int k = a[i].length();
		if(k<12){
			cout << a[i]<<endl;
		}else{
				cout << a[i][0] << a[i].length() - 2 << a[i][k-1] << endl;
		}
	}
}


#include <string>
#include <iostream>
using namespace std;

void main() {
	int nTests;
	string sample,x;
	cin >> nTests;

	for (int i = 1; i < nTests+1; i++) {
		cin >> sample;
		if (sample.length() > 10) {
			cout << sample[0] << sample.length()-2 << sample[sample.length-1] << endl;
		}
	}

}


#include <string>
#include <iostream>
using namespace std;

int main() {
	int nTests;
	string sample;
	cin >> nTests;

	for (int i = 0; i < nTests; i++) {
		cin >> sample;
		if (sample.length() > 10) {
			cout << sample[0] << sample.length()-2 << sample[sample.length()-1] << endl;
		}
	}
	return 0;
}


#include <string>
#include <iostream>
using namespace std;

int main() {
	int nTests;
	string sample,x;
	cin >> nTests;

	for (int i = 0; i < nTests; i++) {
		cin >> sample;
		if (sample.length() > 10) {
			cout << sample[0] << sample.length()-2 << sample[sample.length-1] << endl;
		}
	}
	return 0;
}


#include <string>
#include <iostream>
using namespace std;

int main() {
	int nTests;
	string sample,x;
	cin >> nTests;

	for (int i = 1; i < nTests+1; i++) {
		cin >> sample;
		if (sample.length() > 10) {
			cout << sample[0] << sample.length()-2 << sample[sample.length-1] << endl;
		}
	}
	return 0;
}


#include <string>
#include <iostream>
using namespace std;

void main() {
	int nTests;
	string sample,x;
	cin >> nTests;

	for (int i = 1; i < nTests; i++) {
		cin >> sample;
		if (sample.length() > 10) {
			cout << sample[0] << sample[sample.length()] << sample.length() - 2 << endl;
		}
	}

}


#include <string>
#include <iostream>
using namespace std;

void main() {
	int nTests;
	string sample;
	cin >> nTests;

	for (int i = 1; i < 5; i++) {
		cin >> sample;
		if (sizeof(sample) >= 10) {
			cout << sample[0] << sample[sizeof(sample)] << sizeof(sample) - 2;
		}
	}

}


#include <string>
#include <iostream>
using namespace std;

void main() {
	int nTests;
	string sample,x;
	cin >> nTests;

	for (int i = 1; i < nTests; i++) {
		cin >> sample;
		if (sample.length() > 10) {
			cout << sample[0] << sample[sample.length()-1] << sample.length() - 2 << endl;
		}
	}

}


#include <string>
#include <iostream>
using namespace std;

int main() {
	int nTests;
	string sample;
	cin >> nTests;

	for (int i = 0; i < nTests; i++) {
		cin >> sample;
		if (sample.length() > 10) {
			cout << sample[0] << sample.length() - 2 << sample[sample.length() - 1] << endl;
		}
		else cout << sample << endl;
	}
	return 0;
}


#include <string>
#include <iostream>
using namespace std;

void main() {
	int nTests;
	string sample;
	cin >> nTests;

	for (int i = 1; i < nTests; i++) {
		cin >> sample;
		if (sample.length() > 10) {
			cout << sample[0] << sample[sample.length()] << sample.length() - 2 << endl;
		}
	}

}


#include <string>
#include <iostream>
using namespace std;

void main() {
	int nTests;
	string sample;
	cin >> nTests;

	for (int i = 1; i < 5; i++) {
		cin >> sample;
		if (sample.length() > 10) {
			cout << sample[0] << sample[sample.length()] << sample.length() - 2;
		}
	}

}


#include <iostream>
#include<string>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int a;
	cin>>a;
	while(a!=0){string b;
	cin>>b;
if(b.length()<=10){cout<<b;
	}
if(b.length()>10){int f;
f=b.length();
int d=f-1;
		cout<<b.at(0)<<f-2<<b.at(d)<<"\n";
	}

a--;	}
	return 0;
}


#include <iostream>
using namespace std;
void main (){
	int n,m,a,i,k,y;
		cin >> n >> m >> a;
		if (n % a == 0)
			i=n \ a;
		else
			i = n \ a +1;
		if (m % a == 0 )
			k=m \ a;
		else
			k=m \ a+1;
		y=k*n;
		cout <<y;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

void main()
{
	int n;
	char word[100];
	cin>>n;
	while(n--)
	{
		cin>>word;
	int length= strlen (word);
	if(length >=10)
		cout<<word[0]<<length-2<<word[length-1];
	else
		cout<<word;
	}
}


[Project]
FileName=way too long words main.dev
Name=way too long words
Type=1
Ver=2
ObjFiles=
Includes=
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=
IsCpp=1
Icon=
ExeOutput=
ObjectOutput=
LogOutput=
LogOutputEnabled=0
OverrideOutput=0
OverrideOutputName=
HostApplication=
UseCustomMakefile=0
CustomMakefile=
CommandLine=
Folders=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=0000000000000000000000000
UnitCount=1

[VersionInfo]
Major=1
Minor=0
Release=0
Build=0
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileDescription=Developed using the Dev-C++ IDE
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
AutoIncBuildNr=0
SyncProduct=1

[Unit1]
FileName=way too long wordsmain.cpp
CompileCpp=1
Folder=
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=


#include<iostream>
using namespace std;
int main(){
int a;
cin>>a;
char**x=new char*[a];{
     for(int c=0;c<a;c++)x[c]=[10];

}
string b;
for(int i=0; i<a; i++){
     cin>>b;
     if(b.length()<=10)for(int v=0;v<b.length(); v++)x[i][v]=b.at(v);
     else{ x[0]=b.at(0);
        int z=b.length()-2;
        x[1]=z;
        int f=b.length()-1;
        x[2]=b.at(f);

     }
     for(int i=0;i<a;i++){
          for(int r=0;r<10;r++)cout<<x[i][r];

     }

}
return 0;}


#include <iostream>
using namespace std;
void main(){
	int n,k,i,max,counter=0;
	cin>>n>>k;
	int a[51];
	for(i=0;i<n;i++)
	{cin>>a[i];
	if(i+1==k)
      max= a[i];
	}
	for(i=0;i<n;i++)
	if(a[i]>=max && a[i] > 0 )
		counter+=1;
		cout<<endl<<counter<<endl;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

void main()
{
	int n;
	char word[100];
	cin>>n;
	while(n--)
	{
		cin>>word;
	int length= strlen (word);
	if(length >=10)
		cout<<word[0]<<length-2<<word[length-1];
	else
		cout<<word;
	 }
}


#include <iostream>
#include <cstdio>
#include <cstring>
 using namespace std;

void main()
{
	int n,length;
	char word[100][100];
	cin>>n;
	int x=n-1;
	while(n--)
	{
		cin>>word[n];
	}
	for(;x>=0;x--) {
		length= strlen (word[x]);
	if(length >10) {
		cout<<word[x][0]<<length-2<<word[x][length-1]<<endl;
	}
	else cout<<word[x]<<endl;
	}}


#include<iostream>
#include<string>
using namespace std;
int main() {
	int a;
	cin >> a;
	string b;
	int**x = new int*[a];
	for (int i = 0; i < a; i++)x[i] = new int[12];

	for (int v = 0; v < a; v++) {
		cin >> b;
		if (b.length() < 11) {
			for (int q = 0; q < b.length(); q++) {
				x[v][q] = b.at(q);
			}   x[v][10] = b.length();
			x[v][11] = 't';

		}

		else {
			int dd = b.length();
			int o = dd - 1;
			x[v][0] = b.at(0);
			x[v][1] = b.length() - 2;
			x[v][2] = b.at(o);
			x[v][11] = 's';

		}
	                              }

	for (int z = 0; z < a; z++) {
		if (x[z][11] == 't') {
			for (int r = 0; r < x[z][10]; r++) { char bbb = x[z][r]; cout << bbb; }
			cout << endl;

		                                      }

		else {
			char v1 = x[z][0],v2= x[z][2];
			cout <<v1 << x[z][1] <<v2<<endl;

					  }

	}

	return 0;
         }


#include <iostream>
#include <cstdio>
#include <cstring>
 using namespace std;

void main()
{
	int n,length;
	char word[100][100];
	cin>>n;
	int x=n-1;
	while(n--)
	{
		cin>>word[n];
	}
	for(;x>=0;x--) {
		length= strlen (word[x]);
	if(length >=10) {
		cout<<word[x][0]<<length-2<<word[x][length-1]<<endl;
	}
	else cout<<word[x]<<endl;
	}}


#include <iostream>
#include<string>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int a; string b;
	cin>>a;
	while(a!=0){
	cin>>b;
if(b.length()<=10){cout<<b;
	}
if(b.length()>10){int f;
f=b.length();
int d=f-1;
		cout<<b.at(0)<<f-2<<b.at(d)<<"\n";
	}
		a--;}

	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

void main()
{
	int n;
	char word[100];
	cin>>n;
	while(n--)
	{
		cin>>word;
	int length= strlen (word);
	if(length >=10)
		cout<<word[0]<<length-2<<word[length-1];
	else
		cout<<word<<endl;
	 }
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	char s[100][100];
	for(i=0;i<=n;i++)
	{

		cin.getline(s[i],100);
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;s[i][j];j++);
		tool[i]=0;

		tool[i]=j;

		if(tool[i]>10)
		{
			if(j==99)
			{
				j=100;
				tool[i]=100;
				cout<<s[i][0]<<tool[i]-2;
				cout<<s[i][j-2]<<endl;
			}
			else
			{
				cout<<s[i][0]<<tool[i]-2;
				cout<<s[i][j-1]<<endl;
			}
		}
		else
		{
			cout<<s[i]<<endl;;
		}

	}

}


using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	string ds[100];
	for(i=0;i<n;i++)
	{
		if(i==0)
		{
		cin.get();
		}
		getline(cin,ds[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;ds[i][j];j++);
		tool[i]=0;
		tool[i]=j;

		if(tool[i]>10)
		{
				cout<<ds[i][0]<<tool[i]-2;
				cout<<ds[i][j-1]<<endl;
		}
		else
		{
			cout<<ds[i]<<endl;;
		}

	}

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	string ds[100];
	for(i=0;i<=n;i++)
	{

		getline(cin,ds[i]);
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;ds[i][j];j++);
		tool[i]=0;

		tool[i]=j;

		if(tool[i]>10)
		{
				cout<<ds[i][0]<<tool[i]-2;
				cout<<ds[i][j-1]<<endl;
		}
		else
		{
			cout<<ds[i]<<endl;;
		}

	}

}


using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	string g[100];
	for(i=0;i<n;i++)
	{
		if(i==0)
		{
		cin.get();
		}
		getline(cin,g[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;g[i][j];j++);
		tool[i]=0;
		tool[i]=j;

		if(tool[i]>10)
		{
				cout<<g[i][0]<<tool[i]-2;
				cout<<g[i][j-1]<<endl;
		}
		else
		{
			cout<<g[i]<<endl;;
		}

	}

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	string v[100];
	for(i=0;i<n;i++)
	{
		if(i==0)
		{
		cin.get();
		}
		getline(cin,v[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;e[i][j];j++);
		tool[i]=0;
		tool[i]=j;

		if(tool[i]>10)
		{
				cout<<v[i][0]<<tool[i]-2;
				cout<<v[i][j-1]<<endl;
		}
		else
		{
			cout<<v[i]<<endl;;
		}

	}

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	char s[100][100];
	for(i=0;i<=n;i++)
	{

		cin.getline(s[i],100);
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;s[i][j];j++);
		 tool[i]=0;
		 tool[i]=j;
		  if(tool[i]>10)
		  {
	cout<<s[i][0]<<tool[i]-2;
	cout<<s[i][j-1]<<endl;
		  }
		  else
		  {
			  cout<<s[i]<<endl;;
		  }

	}

	}


using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	string ds[100];
	for(i=0;i<n;i++)
	{
		if(i==0)
		{
		cin.get();
		}
		getline(cin,ds[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;ds[i][j];j++);
		tool[i]=0;
		tool[i]=j;

		if(tool[i]>10)
		{
				cout<<ds[i][0]<<tool[i]-2;
				cout<<ds[i][j-1]<<endl;
		}
		else
		{
			cout<<ds[i]<<endl;;
		}

	}
	system("pause");

}


using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	string s[100];
	for(i=0;i<n;i++)
	{
		if(i==0)
		{
		cin.get();
		}
		getline(cin,s[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;s[i][j];j++);
		tool[i]=0;
		tool[i]=j;

		if(tool[i]>10)
		{
				cout<<s[i][0]<<tool[i]-2;
				cout<<s[i][j-1]<<endl;
		}
		else
		{
			cout<<s[i]<<endl;;
		}

	}
	system("pause");

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	char s[100][100];
	for(i=0;i<=n;i++)
	{

		cin.getline(s[i],100);
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;s[i][j];j++);
		tool[i]=0;

		tool[i]=j;

		if(tool[i]>10)
		{
			if(j==99)
			{
				j=100;
				cout<<s[i][0]<<tool[i]-2;
				cout<<s[i][j-2]<<endl;
			}
			else
			{
				cout<<s[i][0]<<tool[i]-2;
				cout<<s[i][j-1]<<endl;
			}
		}
		else
		{
			cout<<s[i]<<endl;;
		}

	}

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	string s[100];
	for(i=0;i<=n;i++)
	{

		getline(cin,s[i]);
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;s[i][j];j++);
		tool[i]=0;

		tool[i]=j;

		if(tool[i]>10)
		{
				cout<<s[i][0]<<tool[i]-2;
				cout<<s[i][j-1]<<endl;
		}
		else
		{
			cout<<s[i]<<endl;;
		}

	}

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	char s[100][100];
	for(i=0;i<=n;i++)
	{

		cin.getline(s[i],100);
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;s[i][j];j++);
		 tool[i]=0;
		 if(j==99)
		 {
			 j=100;
		 }
		 tool[i]=j;

		  if(tool[i]>10)
		  {
	cout<<s[i][0]<<tool[i]-2;
	cout<<s[i][j-1]<<endl;
		  }
		  else
		  {
			  cout<<s[i]<<endl;;
		  }

	}
	system("pause");
	}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	string q[100];
	for(i=0;i<n;i++)
	{
		if(i==0)
		{
		cin.get();
		}
		getline(cin,q[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;q[i][j];j++);
		tool[i]=0;
		tool[i]=j;

		if(tool[i]>10)
		{
				cout<<q[i][0]<<tool[i]-2;
				cout<<q[i][j-1]<<endl;
		}
		else
		{
			cout<<q[i]<<endl;;
		}

	}

}


using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	string r[100];
	for(i=0;i<n;i++)
	{
		if(i==0)
		{
		cin.get();
		}
		getline(cin,r[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;s[i][j];j++);
		tool[i]=0;
		tool[i]=j;

		if(tool[i]>10)
		{
				cout<<r[i][0]<<tool[i]-2;
				cout<<r[i][j-1]<<endl;
		}
		else
		{
			cout<<r[i]<<endl;;
		}

	}

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	char s[100][100];
	for(i=0;i<=n;i++)
	{

		cin.getline(s[i],100);
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;s[i][j];j++);
		 tool[i]=0;
		 if(j==99)
		 {
			 j=100;
		 }
		 tool[i]=j;
		 cout<<tool[i];
		  if(tool[i]>10)
		  {
	cout<<s[i][0]<<tool[i]-2;
	cout<<s[i][j-1]<<endl;
		  }
		  else
		  {
			  cout<<s[i]<<endl;;
		  }

	}
	system("pause");
	}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	char s[100][100];
	for(i=0;i<=n;i++)
	{

		cin.getline(s[i],100);
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;s[i][j];j++);
		 tool[i]=0;
		 if(j==99)
		 {
			 j=100;
			 cout<<s[i][0]<<tool[i]-2;
	          cout<<s[i][j-2]<<endl;
		 }
		 tool[i]=j;

		  if(tool[i]>10)
		  {
	cout<<s[i][0]<<tool[i]-2;
	cout<<s[i][j-1]<<endl;
		  }
		  else
		  {
			  cout<<s[i]<<endl;;
		  }

	}

	}


#include<iostream>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	string g[100];
	for(i=0;i<n;i++)
	{
		if(i==0)
		{
		cin.get();
		}
		getline(cin,g[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;g[i][j];j++);
		tool[i]=0;
		tool[i]=j;

		if(tool[i]>10)
		{
				cout<<g[i][0]<<tool[i]-2;
				cout<<g[i][j-1]<<endl;
		}
		else
		{
			cout<<g[i]<<endl;;
		}

	}

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	int tool[100];
	char s[100][100];
	for(i=0;i<=n;i++)
	{

		cin.getline(s[i],100);
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;s[i][j];j++);
		tool[i]=0;

		tool[i]=j;

		if(tool[i]>10)
		{
			if(j==99)
			{
				j=100;
				cout<<s[i][0]<<tool[i]-2;
				cout<<s[i][j-1]<<endl;
			}
			else
			{
				cout<<s[i][0]<<tool[i]-2;
				cout<<s[i][j-1]<<endl;
			}
		}
		else
		{
			cout<<s[i]<<endl;;
		}

	}

}


#include<bits/stdc++.h>
using namespace std;
int a,b;
int FindMaximum(int low, int high)
{
    if(low>a || low>b)
        return -1;
    else if(high>a || high>b)
        high=(a<b)?a:b;
    for(int i=high; i>=low; i--) {
        if(!(a%i) && !(b%i))
            return i;
    }
    return -1;
}
int main()
{
    cin>>a>>b;
    int q,high,low;
    cin>>q;
    for(int i=0; i<q; i++) {
        cin>>low>>high;
        cout<<FindMaximum(low,high)<<endl;
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef stringstream ss;
typedef priority_queue<pii, vector<pii>, greater<pii> > PQ;
typedef pair<pii, int> circ;

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define clr(t,v) memset((t),(v),sizeof(t))
#define p(a) cout << #a << ": " << a << endl;

#define rep(i,n) for(int i=0,_##i=(n);i<_##i;++i)
#define dwn(i,n) for(int i=(n);--i>=0;)
#define repr(i,l,r) for(int i=(l),_##i=(r);i<_##i;++i)
#define dwnr(i,l,r) for(int i=(r),_##i=(l);--i>=_##i;)
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(),_##i=(a).end();i!=_##i;++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(),_##i=(a).rend();i!=_##i;++i)
const int inf = 1 << 30;
char buf[1000];
string nextLine(int length = 100) {
	cin.getline(buf, length);
	string s(buf);
	return s;
}
string next(int length = 100) {
	string tmp;
	cin >> tmp;
	return tmp;
}

int nextInt() {
	int tmp;
	scanf("%d", &tmp);
	return tmp;
}
vi divs;
void prec(int d) {
	for (int i = 2; i * i <= d; i++) {
		if (d % i == 0) {
			divs.pb(i);
		}
	}
	if (d != 1)
		divs.pb(d);
}
int main() {
	int a = nextInt(), b = nextInt();
	int d = __gcd(a, b);
	prec(d);
	int n = nextInt();
	rep(i,n) {
		int low = nextInt(), high = nextInt();
		int ans = -1;
		repi(i,divs) {
			if (*i >= low && *i <= high) {
				ans = max(ans, *i);
			}
		}
		cout << ans << "\n";
	}
}


#include <cstdio>
#include <vector>

using namespace std;

#define repi(i, a) for(typeof((a).begin()) i = (a).begin(), _##i = (a).end(); i != _##i; ++i)

vector<int> factors;

int go(int a, int b) {
    int m = -1;
    repi(i, factors) {
        if (*i >= a && *i <= b) {
            m = max(m, *i);
        }
    }
    return m;
}

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    int c = gcd(a, b);
    for(int i = 1; i * i <= c; ++i) {
        if (c % i == 0) {
            factors.push_back(i);
        }
    }

    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) {
        int low, high;
        scanf("%d %d", &low, &high);
        int ans = go(low, high);
        printf("%d\n", ans);
    }
    return 0;
}


#include <cstdio>
#include <vector>

using namespace std;

#define repi(i, a) for(typeof((a).begin()) i = (a).begin(), _##i = (a).end(); i != _##i; ++i)

vector<int> factors;

int go(int a, int b) {
    int m = -1;
    repi(i, factors) {
        if (*i >= a && *i <= b) {
            m = max(m, *i);
        }
    }
    return m;
}

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    int c = gcd(a, b);
    for(int i = 1; i * i <= c; ++i) {
        if (c % i == 0) {
            factors.push_back(i);
            factors.push_back(c / i);
        }
    }

    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) {
        int low, high;
        scanf("%d %d", &low, &high);
        int ans = go(low, high);
        printf("%d\n", ans);
    }
    return 0;
}


#include <cstdio>
#include <vector>

using namespace std;

#define repi(i, a) for(typeof((a).begin()) i = (a).begin(), _##i = (a).end(); i != _##i; ++i)

vector<int> factors;

int go(int a, int b) {
    int m = -1;
    repi(i, factors) {
        if (*i >= a && *i <= b) {
            m = max(m, *i);
        }
    }
    return m;
}

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    int c = gcd(a, b);
    for(int i = 1; i * i <= c; ++i) {
        if (c % i == 0) {
            factors.push_back(c);
        }
    }

    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) {
        int low, high;
        scanf("%d %d", &low, &high);
        int ans = go(low, high);
        printf("%d\n", ans);
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef stringstream ss;
typedef priority_queue<pii, vector<pii>, greater<pii> > PQ;
typedef pair<pii, int> circ;

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define clr(t,v) memset((t),(v),sizeof(t))
#define p(a) cout << #a << ": " << a << endl;

#define rep(i,n) for(int i=0,_##i=(n);i<_##i;++i)
#define dwn(i,n) for(int i=(n);--i>=0;)
#define repr(i,l,r) for(int i=(l),_##i=(r);i<_##i;++i)
#define dwnr(i,l,r) for(int i=(r),_##i=(l);--i>=_##i;)
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(),_##i=(a).end();i!=_##i;++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(),_##i=(a).rend();i!=_##i;++i)
const int inf = 1 << 30;
char buf[1000];
string nextLine(int length = 100) {
	cin.getline(buf, length);
	string s(buf);
	return s;
}
string next(int length = 100) {
	string tmp;
	cin >> tmp;
	return tmp;
}

int nextInt() {
	int tmp;
	scanf("%d", &tmp);
	return tmp;
}
vi divs;
void prec(int d) {
	for (int i = 1; i*i <= d; i++) {
		if (d % i == 0) {
			divs.pb(i);
			divs.pb(d/i);
		}
	}
}
int main() {
	int a = nextInt(), b = nextInt();
	int d = __gcd(a, b);
	prec(d);
	int n = nextInt();
	rep(i,n) {
		int low = nextInt(), high = nextInt();
		int ans = -1;
		repi(i,divs) {
			if (*i >= low && *i <= high) {
				ans = max(ans, *i);
			}
		}
		cout << ans << "\n";
	}
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef stringstream ss;
typedef priority_queue<pii, vector<pii>, greater<pii> > PQ;
typedef pair<pii, int> circ;

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define clr(t,v) memset((t),(v),sizeof(t))
#define p(a) cout << #a << ": " << a << endl;

#define rep(i,n) for(int i=0,_##i=(n);i<_##i;++i)
#define dwn(i,n) for(int i=(n);--i>=0;)
#define repr(i,l,r) for(int i=(l),_##i=(r);i<_##i;++i)
#define dwnr(i,l,r) for(int i=(r),_##i=(l);--i>=_##i;)
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(),_##i=(a).end();i!=_##i;++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(),_##i=(a).rend();i!=_##i;++i)
const int inf = 1 << 30;
char buf[1000];
string nextLine(int length = 100) {
	cin.getline(buf, length);
	string s(buf);
	return s;
}
string next(int length = 100) {
	string tmp;
	cin >> tmp;
	return tmp;
}

int nextInt() {
	int tmp;
	scanf("%d", &tmp);
	return tmp;
}
vi divs;
void prec(int d) {
	for (int i = 1; i * i <= d; i++) {
		if (d % i == 0) {
			divs.pb(i);
		}
	}
	if (d != 1)
		divs.pb(d);
}
int main() {
	int a = nextInt(), b = nextInt();
	int d = __gcd(a, b);
	prec(d);
	int n = nextInt();
	rep(i,n) {
		int low = nextInt(), high = nextInt();
		int ans = -1;
		repi(i,divs) {
			if (*i >= low && *i <= high) {
				ans = max(ans, *i);
			}
		}
		cout << ans << "\n";
	}
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#define CL(x) memset(x,0,sizeof(x))
#define rep(i,s,t) for(int i=(s);i<=(t);i++)
#define dow(i,s,t) for(int i=(s);i>=(t);i--)
using namespace std;
typedef long long LL;
LL read(){
    LL ret=0,f=1;
    char x=getchar();
    while(!(x>='0' && x<='9')){if(x=='-')f=-1;x=getchar();}
    while(x>='0' && x<='9') ret=ret*10+x-'0', x=getchar();
    return ret*f;
}
char get_char(){
    char x=getchar();
    while(!((x>='a' && x<='z')||(x>='A' && x<='Z'))) x=getchar();
    return x;
}

const int MN=1e5+10;
int N,A,B;
int is_d[MN];
int p[MN],pn;
int find(int n){
    int l=1,r=pn;
    while(l<r){
        int mid=(l+r)/2;
        if(p[mid]<=n) l=mid+1;
        else r=mid;
    }
    if(p[l]>n) l--;
    if(l<0 || p[l]>n) return -1;
    else return p[l];
}
int main(){
    //freopen("in.txt","r",stdin);
    A=read(), B=read(), N=read();
    int m=sqrt(min(A,B))+2;
    rep(i,2,m) if(A%i==0 && B%i==0)
        p[++pn]=i;
    if(B%A==0) p[++pn]=A;
    sort(p,p+pn);
    rep(i,1,N){
        int a=read(), b=read();
        int n=find(b);
        if(n<a) n=-1;
        printf("%d\n",n);
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#define CL(x) memset(x,0,sizeof(x))
#define rep(i,s,t) for(int i=(s);i<=(t);i++)
#define dow(i,s,t) for(int i=(s);i>=(t);i--)
using namespace std;
typedef long long LL;
LL read(){
    LL ret=0,f=1;
    char x=getchar();
    while(!(x>='0' && x<='9')){if(x=='-')f=-1;x=getchar();}
    while(x>='0' && x<='9') ret=ret*10+x-'0', x=getchar();
    return ret*f;
}
char get_char(){
    char x=getchar();
    while(!((x>='a' && x<='z')||(x>='A' && x<='Z'))) x=getchar();
    return x;
}

const int MN=1e6+10;
int N,A,B;
int is_d[MN];
int p[MN],pn;
int find(int n){
    int l=1,r=pn;
    while(l<r){
        int mid=(l+r)/2;
        if(p[mid]==n) return n;
        else if(p[mid]<n) l=mid+1;
        else r=mid;
    }
    if(p[l]>n) l--;
    if(l<1) return -1;
    else return p[l];
}
int main(){
    //freopen("in.txt","r",stdin);
    A=read(), B=read(), N=read();
    int m=sqrt(min(A,B))+2;
    rep(i,2,m) if(A%i==0 && B%i==0)
        p[++pn]=i,p[++pn]=A/i,p[++pn]=B/i;
    if(B%A==0) p[++pn]=A;
    sort(p,p+pn);
    rep(i,1,N){
        int a=read(), b=read();
        int n=find(b);
        if(n<a) n=-1;
        printf("%d\n",n);
    }
    return 0;
}