#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

bool matrix[4][4];

string hexToDec(string &a){
    string b;
    long int i = 0;

    while (a[i]) {
        switch (a[i]) {
            case '0':
                b += "0000";
                break;
            case '1':
                b += "0001";
                break;
            case '2':
                b += "0010";
                break;
            case '3':
                b += "0011";
                break;
            case '4':
                b += "0100";
                break;
            case '5':
                b += "0101";
                break;
            case '6':
                b += "0110";
                break;
            case '7':
                b += "0111";
                break;
            case '8':
                b += "1000";
                break;
            case '9':
                b += "1001";
                break;
            case 'A':
                b += "1010";
                break;
            case 'B':
                b += "1011";
                break;
            case 'C':
                b +="1100";
                break;
            case 'D':
                b += "1101";
                break;
            case 'E':
                b += "1110";
                break;
            case 'F':
                b += "1111";
                break;
            default:
                b += "error";
        }
        i++;
    }
    return b;
}


void stringToMatrix(string b){
    for (int i = 0; i < b.length(); ++i) {
        int y = floor(i / 4);
        matrix[y][i % 4] = b[i] == '1';
    }
}



string groupFour(int i, int j){

        if(matrix[i][j] && matrix[i][j + 1] && matrix[i + 1][j] && matrix[i + 1][j + 1]){
            if(i == 0 && j == 0 ){
                return "AB";
            }
            else if (i == 0 && j == 1){
                return "BC";
            }
            else if(i == 0 && j == 2){
                return "~AB";
            }
            else if(i == 1 && j == 0){
                return "AD";

            }
            else if(i == 1 && j == 1){
                return "CD";

            }
            else if(i == 1 && j == 2){
                return "~AD";
            }
            else if(i == 2 && j == 0){
                return "A~B";
            }
            else if(i == 2 && j == 1){
                return "~BC";
            }
            else if(i == 2 && j == 2){
                return "~A~B";
            }
    }
        return "help";
}



string groupTwoColumn(int i, int j){
    if(matrix[i][j] && matrix[i + 1][j]){
        if(i == 0 && j == 0){
            return "AB~C";
        }
        else if(i == 1 && j == 0){
            return "A~CD";
        }
        else if(i == 2 && j == 0){
            return "A~B~C";
        }
        else if(i == 0 && j == 1){
            return "ABC";
        }
        else if(i == 1 && j == 1){
            return "ACD";
        }
        else if(i == 2 && j == 1){
            return "A~BC";
        }

        else if(i == 0 && j == 2){
            return "~ABC";
        }
        else if(i == 1 && j == 2){
            return "~ACD";
        }
        else if(i == 2 && j == 2){
            return "~A~BC";
        }

        else if(i == 0 && j == 3){
            return "~AB~C";
        }
        else if(i == 1 && j == 3){
            return "~A~CD";
        }

        else if(i == 2 && j == 3){
            return "~A~B~C";
        }
    }
    return "help";
}

string groupTwoRow(int i, int j){
    if(matrix[i][j] && matrix[i][j + 1]){
        if(i == 0 && j == 0){
            return "AB~D";
        }
        else if(i == 0 && j == 1){
            return "BC~D";
        }
        else if(i == 0 && j == 2){
            return "~AB~D";
        }
        else if(i == 1 && j == 0){
            return "ABD";
        }
        else if(i == 1 && j == 1){
            return "BCD";
        }
        else if(i == 1 && j == 2){
            return "~ABD";
        }
        else if(i == 2 && j == 0){
            return "A~BD";
        }
        else if(i == 2 && j == 1){
            return "~BCD";
        }
        else if(i == 2 && j == 2){
            return "~A~BD";
        }
        else if(i == 3 && j == 0){
            return "A~B~D";
        }
        else if(i == 3 && j == 1){
            return "~BC~D";
        }
        else if(i == 3 && j == 2){
            return "~A~B~D";
        }
    }
    return "help";

}

string groupTwoEdgeColumn(int j){
    if(matrix[0][j] && matrix[3][j]){
        if(j == 0){
            return "A~C~D";
        }
        else if(j == 1){
            return "AC~D";
        }
        else if (j == 2){
            return "~AC~D";
        }
        else if(j == 3){
            return "~A~C~D";
        }
    }
    return "help";
}

string groupTwoEdgeRow(int i){
    if(matrix[i][0] && matrix[i][3]){
        if(i == 0){
            return "B~C~D";
        }
        else if(i == 1){
            return "B~CD";
        }
        else if (i == 2){
            return "~B~CD";
        }
        else if(i == 3){
            return "~B~C~D";
        }
    }
    return "help";
}

string onePiece(int i, int j){
    if(i == 0 && j == 0){
        return "AB~C~D";
    }
    else if(i == 0 && j == 1){
        return "ABC~D";
    }
    else if(i == 0 && j == 2){
        return "~ABC~D";
    }
    else if(i == 0 && j == 3){
        return "~AB~C~D";
    }
    else if(i == 1 && j == 0){
        return "AB~CD";
    }
    else if(i == 1 && j == 1){
        return "ABCD";
    }
    else if(i == 1 && j == 2){
        return "~ABCD";
    }
    else if(i == 1 && j == 3){
        return "~AB~CD";
    }
    else if(i == 2 && j == 0){
        return "A~B~CD";
    }
    else if(i == 2 && j == 1){
        return "A~BCD";
    }
    else if(i == 2 && j == 2){
        return "~A~BCD";
    }
    else if(i == 2 && j == 3){
        return "~A~B~CD";
    }
    else if(i == 3 && j == 0){
        return "A~B~C~D";
    }
    else if(i == 3 && j == 1){
        return "A~BC~D";
    }
    else if(i == 3 && j == 2){
        return "~A~BC~D";
    }
    else if(i == 3 && j == 3){
        return "~A~B~C~D";
    }
    return "help";
}



int main(){
    freopen("sr-sample-input.txt", "r", stdin);
    //freopen("sr-sample-output.txt", "w+", stdout);
    for (int i2 = 0; i2 < 5; ++i2) {
        string a;
        cin >> a;
        string b = hexToDec(a);
        stringToMatrix(b);

        /*for (int i1 = 0; i1 < 4; ++i1) {
            for (int i = 0; i < 4; ++i) {
                cout << matrix[i1][i] << " ";
            }
            cout << "\n";
        }
        cout << "\n";*/

        set> excluded;
        vector res;


        if(matrix[0][0] && matrix[0][1] && matrix[0][2] && matrix[0][3] && matrix[1][0] && matrix[1][1] && matrix[1][2] && matrix[1][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 3))) ){
                excluded.emplace(make_pair(0, 0));
                excluded.emplace(make_pair(0, 1));
                excluded.emplace(make_pair(0, 2));
                excluded.emplace(make_pair(0, 3));
                excluded.emplace(make_pair(1, 0));
                excluded.emplace(make_pair(1, 1));
                excluded.emplace(make_pair(1, 2));
                excluded.emplace(make_pair(1, 3));
                res.push_back("B");
            }
        }
        if(matrix[1][0] && matrix[1][1] && matrix[1][2] && matrix[1][3] && matrix[2][0] && matrix[2][1] && matrix[2][2] && matrix[2][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(1, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 3))) ){
                excluded.emplace(make_pair(1, 0));
                excluded.emplace(make_pair(1, 1));
                excluded.emplace(make_pair(1, 2));
                excluded.emplace(make_pair(1, 3));
                excluded.emplace(make_pair(2, 0));
                excluded.emplace(make_pair(2, 1));
                excluded.emplace(make_pair(2, 2));
                excluded.emplace(make_pair(2, 3));
                res.push_back("D");
            }

        }
        if(matrix[2][0] && matrix[2][1] && matrix[2][2] && matrix[2][3] && matrix[3][0] && matrix[3][1] && matrix[3][2] && matrix[3][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(2, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 3))) ){
                excluded.emplace(make_pair(2, 0));
                excluded.emplace(make_pair(2, 1));
                excluded.emplace(make_pair(2, 2));
                excluded.emplace(make_pair(2, 3));
                excluded.emplace(make_pair(3, 0));
                excluded.emplace(make_pair(3, 1));
                excluded.emplace(make_pair(3, 2));
                excluded.emplace(make_pair(3, 3));
                res.push_back("~B");
            }
        }
        if(matrix[0][0] && matrix[1][0] && matrix[2][0] && matrix[3][0] && matrix[0][1] && matrix[1][1] && matrix[2][1] && matrix[3][1]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 1)) ||  binary_search(excluded.begin(), excluded.end(), make_pair(3, 1)))){
                excluded.emplace(make_pair(0, 0));
                excluded.emplace(make_pair(1, 0));
                excluded.emplace(make_pair(2, 0));
                excluded.emplace(make_pair(3, 0));
                excluded.emplace(make_pair(0, 1));
                excluded.emplace(make_pair(1, 1));
                excluded.emplace(make_pair(2, 1));
                excluded.emplace(make_pair(3, 1));
                res.push_back("A");
            }
        }
        if(matrix[0][1] && matrix[1][1] && matrix[2][1] && matrix[3][1] && matrix[0][2] && matrix[1][2] && matrix[2][2] && matrix[3][2]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 2))) ){
                excluded.emplace(make_pair(0, 1));
                excluded.emplace(make_pair(1, 1));
                excluded.emplace(make_pair(2, 1));
                excluded.emplace(make_pair(3, 1));
                excluded.emplace(make_pair(0, 2));
                excluded.emplace(make_pair(1, 2));
                excluded.emplace(make_pair(2, 2));
                excluded.emplace(make_pair(3, 2));
                res.push_back("C");
            }

        }
        if(matrix[0][2] && matrix[1][2] && matrix[2][2] && matrix[3][2] && matrix[0][3] && matrix[1][3] && matrix[2][3] && matrix[3][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 3))) ){
                excluded.emplace(make_pair(0, 2));
                excluded.emplace(make_pair(1, 2));
                excluded.emplace(make_pair(2, 2));
                excluded.emplace(make_pair(3, 2));
                excluded.emplace(make_pair(0, 3));
                excluded.emplace(make_pair(1, 3));
                excluded.emplace(make_pair(2, 3));
                excluded.emplace(make_pair(3, 3));
                res.push_back("~A");
            }
        }

        if(matrix[0][0] && matrix[1][0] && matrix[2][0] && matrix[3][0] && matrix[0][3] && matrix[1][3] && matrix[2][3] && matrix[3][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 3))) ){
                excluded.emplace(make_pair(0, 0));
                excluded.emplace(make_pair(1, 0));
                excluded.emplace(make_pair(2, 0));
                excluded.emplace(make_pair(3, 0));
                excluded.emplace(make_pair(0, 3));
                excluded.emplace(make_pair(1, 3));
                excluded.emplace(make_pair(2, 3));
                excluded.emplace(make_pair(3, 3));
                res.push_back("~C");
            }
        }
        if(matrix[0][0] && matrix[0][1] && matrix[0][2] && matrix[0][3] && matrix[3][0] && matrix[3][1] && matrix[3][2] && matrix[3][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(0,2)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 3))) ){
                excluded.emplace(make_pair(0, 0));
                excluded.emplace(make_pair(0, 1));
                excluded.emplace(make_pair(0, 2));
                excluded.emplace(make_pair(0, 3));
                excluded.emplace(make_pair(3, 0));
                excluded.emplace(make_pair(3, 1));
                excluded.emplace(make_pair(3, 2));
                excluded.emplace(make_pair(3, 3));
                res.push_back("~D");
            }
        }

        if(matrix[0][0] && matrix[0][1] && matrix[0][2] && matrix[0][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 3)))){
                res.push_back("B~D");
                excluded.emplace(make_pair(0, 0));
                excluded.emplace(make_pair(0, 1));
                excluded.emplace(make_pair(0, 2));
                excluded.emplace(make_pair(0, 3));
            }
        }
        if(matrix[1][0] && matrix[1][1] && matrix[1][2] && matrix[1][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(1, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 3)))){
                res.push_back("BD");
                excluded.emplace(make_pair(1, 0));
                excluded.emplace(make_pair(1, 1));
                excluded.emplace(make_pair(1, 2));
                excluded.emplace(make_pair(1, 3));
            }
        }
        if(matrix[2][0] && matrix[2][1] && matrix[2][2] && matrix[2][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(2, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 3)))){
                res.push_back("~BD");
                excluded.emplace(make_pair(2, 0));
                excluded.emplace(make_pair(2, 1));
                excluded.emplace(make_pair(2, 2));
                excluded.emplace(make_pair(2, 3));
            }
        }
        else if(matrix[3][0] && matrix[3][1] && matrix[3][2] && matrix[3][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(3, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 3)))){
                res.push_back("~B~D");
                excluded.emplace(make_pair(3, 0));
                excluded.emplace(make_pair(3, 1));
                excluded.emplace(make_pair(3, 2));
                excluded.emplace(make_pair(3, 3));
            }
        }

        if(matrix[0][0] && matrix[1][0] && matrix[2][0] && matrix[3][0]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 0)))){
                res.push_back("A~C");
                excluded.emplace(make_pair(0, 0));
                excluded.emplace(make_pair(1, 0));
                excluded.emplace(make_pair(2, 0));
                excluded.emplace(make_pair(3, 0));
            }
        }
        if(matrix[0][1] && matrix[1][1] && matrix[2][1] && matrix[3][1]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 1)))){
                res.push_back("AC");
                excluded.emplace(make_pair(0, 1));
                excluded.emplace(make_pair(1, 1));
                excluded.emplace(make_pair(2, 1));
                excluded.emplace(make_pair(3, 1));
            }
        }
        if(matrix[0][2] && matrix[1][2] && matrix[2][2] && matrix[3][2]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 2)))){
                res.push_back("~AC");
                excluded.emplace(make_pair(0, 2));
                excluded.emplace(make_pair(1, 2));
                excluded.emplace(make_pair(2, 2));
                excluded.emplace(make_pair(3, 2));
            }
        }
        if(matrix[0][3] && matrix[1][3] && matrix[2][3] && matrix[3][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 3)))){
                res.push_back("~A~C");
                excluded.emplace(make_pair(0, 3));
                excluded.emplace(make_pair(1, 3));
                excluded.emplace(make_pair(2, 3));
                excluded.emplace(make_pair(3, 3));
            }
        }

        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if(binary_search(excluded.begin(), excluded.end(), make_pair(i, j)) || binary_search(excluded.begin(), excluded.end(), make_pair(i + 1, j)) || binary_search(excluded.begin(), excluded.end(), make_pair(i, j + 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(i + 1, j + 1))){
                    continue;
                }
                string c = groupFour(i, j);
                if(c != "help"){
                    res.push_back(c);
                    excluded.emplace(make_pair(i, j));
                    excluded.emplace(make_pair(i, j + 1));
                    excluded.emplace(make_pair(i + 1, j));
                    excluded.emplace(make_pair(i + 1, j + 1));
                }
            }
        }


        if (matrix[0][0] && matrix[0][1] && matrix[3][0] && matrix[3][1]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 1)))){
                res.push_back("A~D");
                excluded.emplace(make_pair(0, 0));
                excluded.emplace(make_pair(0, 1));
                excluded.emplace(make_pair(3, 0));
                excluded.emplace(make_pair(3, 1));
            }
        }
        if (matrix[0][1] && matrix[0][2] && matrix[3][1] && matrix[3][2]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 1)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 2)))){
                res.push_back("C~D");
                excluded.emplace(make_pair(0, 1));
                excluded.emplace(make_pair(0, 2));
                excluded.emplace(make_pair(3, 1));
                excluded.emplace(make_pair(3, 2));
            }
        }
        if (matrix[0][2] && matrix[0][3] && matrix[3][2] && matrix[3][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 2)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 3)))){
                res.push_back("~A~D");
                excluded.emplace(make_pair(0, 2));
                excluded.emplace(make_pair(0, 3));
                excluded.emplace(make_pair(3, 2));
                excluded.emplace(make_pair(3, 3));
            }
        }


       if(matrix[0][0] && matrix[1][0] && matrix[0][3] && matrix[1][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 3)))){
                res.push_back("B~C");
                excluded.emplace(make_pair(0, 0));
                excluded.emplace(make_pair(1, 0));
                excluded.emplace(make_pair(0, 3));
                excluded.emplace(make_pair(1, 3));
            }
        }
        if(matrix[1][0] && matrix[2][0] && matrix[1][3] && matrix[2][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(1, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(1, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 3)))){
                res.push_back("~CD");
                excluded.emplace(make_pair(1, 0));
                excluded.emplace(make_pair(2, 0));
                excluded.emplace(make_pair(1, 3));
                excluded.emplace(make_pair(2, 3));
            }
        }
        if(matrix[2][0] && matrix[3][0] && matrix[2][3] && matrix[3][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(2, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(2, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 3)))){
                res.push_back("~B~C");
                excluded.emplace(make_pair(2, 0));
                excluded.emplace(make_pair(3, 0));
                excluded.emplace(make_pair(2, 3));
                excluded.emplace(make_pair(3, 3));
            }
        }


        if(matrix[0][0] && matrix[3][0] && matrix[0][3] && matrix[3][3]){
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(0, 3)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, 3)))){
                res.push_back("~C~D");
                excluded.emplace(make_pair(0, 0));
                excluded.emplace(make_pair(0, 3));
                excluded.emplace(make_pair(3, 0));
                excluded.emplace(make_pair(3, 3));
            }
        }

        for (int k = 0; k< 4; ++k) {
            for (int i = 0; i < 3; ++i) {
                if(matrix[k][i] && matrix[k][i + 1]){
                    if(!(binary_search(excluded.begin(), excluded.end(), make_pair(k, i)) || binary_search(excluded.begin(), excluded.end(), make_pair(k , i + 1)))){
                        string c = groupTwoRow(k, i);
                        if(c != "help"){
                            res.push_back(c);
                            excluded.emplace(make_pair(k, i));
                            excluded.emplace(make_pair(k, i + 1));
                        }
                    }
                }
            }
        }

        for (int i = 0; i < 4; ++i) {
            for (int k = 0; k < 3; ++k) {
                if(matrix[k][i] && matrix[k + 1][i]){
                    if(!(binary_search(excluded.begin(), excluded.end(), make_pair(k, i)) || binary_search(excluded.begin(), excluded.end(), make_pair(k + 1, i)))){
                        string c = groupTwoColumn(k, i);
                        if(c != "help"){
                            res.push_back(c);
                            excluded.emplace(make_pair(k, i));
                            excluded.emplace(make_pair(k + 1, i));
                        }
                    }
                }
            }
        }

        for (int l = 0; l < 4; ++l) {
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(l, 0)) || binary_search(excluded.begin(), excluded.end(), make_pair(l, 3)) )){
                string c = groupTwoEdgeRow(l);
                if(c != "help"){
                    res.push_back(c);
                    excluded.emplace(make_pair(l, 0));
                    excluded.emplace(make_pair(l, 3));
                }
            }
        }

        for (int l = 0; l < 4; ++l) {
            if(!(binary_search(excluded.begin(), excluded.end(), make_pair(0, l)) || binary_search(excluded.begin(), excluded.end(), make_pair(3, l)) )){
                string c = groupTwoEdgeColumn(l);
                if(c != "help"){
                    res.push_back(c);
                    excluded.emplace(make_pair(0, l));
                    excluded.emplace(make_pair(3, l));
                }
            }
        }

        for (int m = 0; m < 4; ++m) {
            for (int i = 0; i < 4; ++i) {
                if(matrix[m][i]){
                    if(!(binary_search(excluded.begin(), excluded.end(), make_pair(m, i)))){
                        string c = onePiece(m, i);
                        if(c != "help"){
                            res.push_back(c);
                        }
                    }
                }
            }
        }

        excluded.clear();

        for (int n = 0; n < res.size(); ++n) {
            cout << res[n];
            if(n != res.size() - 1){
                cout << "+";
            }
        }
        cout << "\n";
    }
}