int t;
// t = 1;
cin >>t;
for(int p = 1; p<=t; p++){
int n;
cin >> n;
int a[n];
 for(int i = 0; i<n; i++){
 	cin >> a[i];
 }
int count = 0;
int ans = 0;
for(int i = 0; i<n-1; i++){
	if(a[i] >a[i+1]){
		count++;
	}
	else if(a[i] < a[i+1]){
		count--;
	}
	if(count == 4 || count == -4){
		ans++;
		count = 0;
	}
}
cout << "Case #" << p <<  ": " << ans  << endl;
}