#include <cstdio>

using namespace std;

char s[3][100], k[6][100];
int kvalifikovanih = 6;
bool kvalifikovani[6];

void combine(int one, int two, int three, int res) {
    int i = 0;
    for (char c : s[one]) {
        if (c == '\0') {
            break;
        }
        k[res][i++] = c;
    }
    for (char c : s[two]) {
        if (c == '\0') {
            break;
        }
        k[res][i++] = c;
    }
    for (char c : s[three]) {
        if (c == '\0') {
            break;
        }
        k[res][i++] = c;
    }
    k[res][i++] = '\0';
}

int main() {
    for (int i = 0; i < 6; ++i) {
        kvalifikovani[i] = true;
    }
    scanf("%s %s %s", &s[0], &s[1], &s[2]);
    combine(0, 1, 2, 0);
    combine(0, 2, 1, 1);
    combine(1, 0, 2, 2);
    combine(1, 2, 0, 3);
    combine(2, 0, 1, 4);
    combine(2, 1, 0, 5);
    for (int i = 0; i < 100; ++i) {
        if (k[i][0] == '\0') {
            break;
        }
        char m = '0';
        for (int j = 0; j < 6; ++j) {
            if (kvalifikovani[j] && k[j][i] > m) {
                m = k[j][i];
            }
        }
        for (int j = 0; j < 6; ++j) {
            if (kvalifikovani[j] && k[j][i] != m) {
                --kvalifikovanih;
                kvalifikovani[j] = false;
            }
        }
        if (kvalifikovanih == 1) {
            break;
        }
    }
    for (int i = 0; i < 6; ++i) {
        if (kvalifikovani[i]) {
            printf("%s", k[i]);
            break;
        }
    }
    return 0;
}