bcdef
abbbc
 z
y
 reddit
abcdef
 abc
aaa
 y
z
 cbxz
aaaa

bccdb
 z
 dfdeed
 aab
 y
 abac

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <vector>

using namespace std;

const int alphabet_size = 26;
const char END = '#';

char next_char(char cur, vector<int> &cnt) {
    --cnt[cur - 'a'];
    if (cnt[cur - 'a']) {
        return cur;
    }
    while (cur != 'z' && !cnt[cur - 'a']) {
        ++cur;
    }
    if (cur == 'z' && !cnt[cur - 'a']) {
        return END;
    }
    return cur;
}

char prev_char(char cur, vector<int> &cnt) {
    --cnt[cur - 'a'];
    if (cnt[cur - 'a']) {
        return cur;
    }
    while (cur != 'a' && !cnt[cur - 'a']) {
        --cur;
    }
    if (cur == 'a' && !cnt[cur - 'a']) {
        return END;
    }
    return cur;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;
    sort(begin(s), end(s));
    vector<int> cnt_a(alphabet_size), cnt_b(alphabet_size);
    int n = s.size();
    for (int i = 0; i < n / 2 + n % 2; ++i) {
        cnt_a[s[i] - 'a']++;
    }
    cin >> s;
    sort(rbegin(s), rend(s));
    for (int i = 0; i < n / 2; ++i) {
        cnt_b[s[i] - 'a']++;
    }
    s = string(s.size(), '?');
    int l = 0;
    int r = s.size() - 1;
    cnt_a['a' - 'a']++;
    cnt_b['z' - 'a']++;
    char cur_a = next_char('a', cnt_a);
    char cur_b = prev_char('z', cnt_b);
    bool backwards = false;
    if (cur_a > cur_b) {
        backwards = true;
        cnt_a['z' - 'a']++;
        cur_a = prev_char('z', cnt_a);
        cnt_b['a' - 'a']++;
        cur_b = next_char('a', cnt_b);
    }
    while (l <= r) {
        //cout << s << " " << cur_a << ":" << cur_b << endl;
        if (!backwards) {
            s[l] = cur_a;
            ++l;
        } else {
            s[r] = cur_a;
            --r;
        }
        if (l > r) {
            break;
        }
        if (cur_a > cur_b && !backwards) {
            backwards = true;
            cnt_a['z' - 'a']++;
            cur_a = 'z';
            cnt_b['a' - 'a']++;
            cur_b = 'a';
        }
        if (backwards) {
            cur_a = prev_char(cur_a, cnt_a);
        } else {
            cur_a = next_char(cur_a, cnt_a);
        }
        if (!backwards) {
            s[l] = cur_b;
            ++l;
        } else {
            s[r] = cur_b;
            --r;
        }
        if (cur_a > cur_b && !backwards) {
            backwards = true;
            cnt_a['z' - 'a']++;
            cur_a = 'z';
            cnt_b['a' - 'a']++;
            cur_b = 'a';
        }
        if (backwards) {
            cur_b = next_char(cur_b, cnt_b);
        } else {
            cur_b = prev_char(cur_b, cnt_b);
        }
    }
    cout << s << endl;
    return 0;
}
