#include "bits/stdc++.h"

using namespace std;

class Random {
public:
    Random() = default;

    Random(std::mt19937::result_type seed) : eng(seed) {}

    long long DrawNumber(long long min, long long max);

private:
    std::mt19937 eng{std::random_device{}()};
};

long long Random::DrawNumber(long long min, long long max) {
    if (max < min)return 0;
    return std::uniform_int_distribution<long long>{min, max}(eng);
}


Random rnd(0);

void generate() {
    ofstream cout("test.in");
    int n = rnd.DrawNumber(1, 4);
    while (n--) {cout<<"AB"[rnd.DrawNumber(0, 1)];}
    cout << endl;
    cout.close();
}
int main() {
    system("g++ -lm -O3 -std=c++17 -DLOCAL -pipe -o /wa.exe ./main.cpp");
    system("g++ -lm -O3 -std=c++17 -pipe -o /ac.exe ./ac.cpp");
    // system("javac Main.java");
    int tc = 1;
    while (1) {
        cerr << "Case " << tc++ << " ";
        generate();
        clock_t bef=clock();
        system("ac.exe <test.in >ac.txt");
        clock_t bet=clock();
        cerr<<(bet-bef-0.0)/CLOCKS_PER_SEC<<" ";
        if (system("wa.exe <test.in >wa.txt"))break;
        clock_t aft=clock();
        cerr<<(aft-bet-0.0)/CLOCKS_PER_SEC<<endl;

        //if (system("java Main <test.in >wa.txt"))break;

        //  cerr << tc++ << endl;
        ifstream acs("ac.txt");
        ifstream was("wa.txt");

        string ac, wa;
        getline(was, wa, (char) EOF);

        getline(acs, ac, (char) EOF);
        was.close();

        acs.close();

        //		cout << ac << endl;
        //		cout << wa << endl;
        //if (ac !="YES\n")
        if (ac != wa)
            break;
    }
}
