//* Problem  : 1720 - Brainman
//* Contest  : acm.tju.edu.cn
//* Type     : Solution
//* Date     : 2007.07.28
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0

#include <stdio.h>

int a[1000], n;

int main()
{
#ifdef _DEBUG
	freopen("1720", "r", stdin);
#endif
	int it, nt, i, j, res;
	scanf("%i", &nt);
	for (it = 1; it <= nt; it++)
	{
		scanf("%i", &n);
		for (i = 0; i < n; i++)
			scanf("%i\n", &a[i]);
		res = 0;
		for (j = 0; j < n - 1; j++)
			for (i = 0; i < n - 1; i++)
				if (a[i] > a[i+1])
				{
					int t = a[i]; a[i] = a[i+1]; a[i+1] = t; res++;
				}
		printf("Scenario #%i:\n", it);
		printf("%i\n", res);
		printf("\n");

	}
}