#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>

void Trace( int *A, int N, int cnt){
	//?????????????????????????????????N-1??¨??????
	for (int i = 0; i < N - 1; i++){
		printf("%d ", A[i]);
	}
	printf("%d\n", A[N - 1]);
	printf("%d\n", cnt);
}

int BubbleSort(int *A, int N){
	int cnt = 0;

	for (int i = N-1; i > 0; i--){
		for (int j = N-1; j >= 0; j--){

			//??\???????????????
			if (A[j - 1] > A[j]){
				int t = A[j - 1];
				A[j - 1] = A[j];
				A[j] = t;
				cnt++;
			}
		}
	}

	return cnt;
}

int main(int argc, char *argv[]){
	int N;

	scanf("%d", &N);

	int *A = (int*)malloc(sizeof(int) * N);

	//??\???
	for (int i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}

	int cnt = BubbleSort(A, N);
	Trace(A, N, cnt);

	free(A);

	return 0;
}
#include <iostream>
#include <string>
#include <stdio.h>

#define N 1000

using namespace std;

int main()
{
	int n;
	int s;
	string str;

	cin >> n;
	cin.ignore();

	for(int i = 0; i < n; i++)
	{
		getline(cin,str);

		for(s = 0; s < N; s++){

		if(str[s] == 'H' && str[s+1] =='o' && str[s+2] == 's' && str[s+3] == 'h' 
			&& str[s+4] == 'i' && str[s+5] == 'n' && str[s+6] == 'o' ){
				
				str[s] = 'H';
				str[s+1] = 'o';
				str[s+2] = 's';
				str[s+3] = 'h';
				str[s+4] = 'i';
				str[s+5] = 'n';
				str[s+6] = 'a';
			}

		}
		cout << str << endl;

	}
}