// Arup Guha
// 6/21/2023
// Solution to SIUCF CP Final Contest Problem: Arithmetic Decoding
// https://open.kattis.com/problems/arithmeticdecoding

using namespace std;
#include <bits/stdc++.h>
typedef long long ll;

ll convert(string s);

int main() {
    int n, num;
    string bits;
    cin >> n >> num >> bits;

    // Getting fraction into lowest terms.
    int group = 3;
    while (num%2 == 0) {
        num /= 2;
        group--;
    }

    // Chop off first 2 chars.
    bits = bits.substr(2, bits.size()-2);

    // To make my life easier...
    while (bits.size() < group*n) bits += "0";

    string res = "";
    ll low = 0, high = (1<<group);
    for (int i=0; i<bits.size(); i+= group) {

        // Grab the bits we care about.
        ll val = convert(bits.substr(0, i+group));

        ll step = (high-low)/(1<<group);
        ll limit = low + num*step;

        // This is what the probability means, then reassign low, high.
        if (val < limit) {
            res += "A";
            low *= (1<<group);
            high = limit*(1<<group);
        }

        // Do a similar thing on the other side.
        else {
            res += "B";
            low = limit*(1<<group);
            high *= (1<<group);
        }
    }

    // Ta da!
    cout << res << endl;
    return 0;
}

// Just convert binary to integer value.
ll convert(string s) {
    ll val = 0;
    for (int i=0; i<s.size(); i++)
        val = 2*val + (s[i]-'0');
    return val;
}
