#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
void aaa (int x,int y,char ab[]){
int i=0,sum_a=0,sum_b=0;
while(i<strlen(ab)){
if(i>=x&&i<y){
if(ab[i]=='b')
sum_a--;
else
sum_b--;
}
else{
if(ab[i]=='a')
sum_a++;
else
sum_b++;
}
i++;
}
if(sum_a==0 || sum_b==0)
cout << x << "," << y <<endl;
}
void circle (char ab[]){
for(int i=0;i<strlen(ab)-1;i++)
for(int j=0;j<strlen(ab);j++){
if(i==j) continue;
aaa(i,j,ab);
}
}
int main(void)
{
char ab[300][1001];
int t=0; // t = 輸入的筆數
do{
cin >> ab[t++];
}while(cin.get()!=EOF&&t<300);
for(int i=0;i<t;i++){
cout << "AB Circle #"<< i+1 << ":" <<endl;
circle(ab[i]);
cout <<endl;
}
return 0;
}