#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<char> olgec(26,0);
  vector<char> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  int l = 0;
  int r = n-1;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.assign(n, '0');
  int total = 0;
  while(total < n)
  {
    while(olgec[oit] == 0)
      oit++;
    if(oit >= iit)
    {
      for(char last = 25; last>=0; last--)
      {
        if(olgec[last])
        {
         ans[r] = last + 'a';
         olgec[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = oit + 'a';
      olgec[oit]--;
      l++;
    }
    total ++;
    if(total == n)
      break;
    while(olgec[oit] == 0)
      oit++;

    while(igorc[iit] == 0)
      iit--;

    if(oit >= iit && total + 1 < n)
    {
      for(char last = 0; last<=25; last++)
      {
        if(igorc[last])
        {
         ans[r] = last + 'a';
         igorc[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = iit + 'a';
      igorc[iit]--;
      l++;
    }

    total++;
  }

  cout << ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<char> olgec(26,0);
  vector<char> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  int l = 0;
  int r = n-1;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.assign(n, '0');
  int total = 0;
  while(total < n)
  {
    while(olgec[oit] == 0)
      oit++;
    if(oit > iit)
    {
      for(char last = 25; last>=0; last--)
      {
        if(olgec[last])
        {
         ans[r] = last + 'a';
         olgec[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = oit + 'a';
      olgec[oit]--;
      l++;
    }
    total ++;
    if(total == n)
      break;

    while(igorc[iit] == 0)
      iit--;

    if(oit > iit)
    {
      for(char last = 0; last<=25; last++)
      {
        if(igorc[last])
        {
         ans[r] = last + 'a';
         igorc[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = iit + 'a';
      igorc[iit]--;
      l++;
    }

    total++;
  }

  cout << ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<char> olgec(26,0);
  vector<char> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  oit = static_cast<char>(25);
  for(int i=0; i<(n+1)/2;)
  {
    while(!olgec[oit])
    {
      oit--;
    }
    int temp = i + min(olgec[oit], (n+1)/2 - i));
    olgec[oit] -= min(olgec[oit], (n+1)/2 - i));
    i = temp;
  }

  iit = static_cast<char>(0);
  for(int i=0; i<(n)/2;)
  {
    while(!igorc[iit])
    {
      iit++;
    }
    int temp = i + min(igorc[iit], (n)/2 - i));
    igorc[iit] -= min(igorc[iit], (n)/2 - i));
    i = temp;
  }

  int l = 0;
  int r = n-1;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.assign(n, '0');
  int total = 0;
  while(total < n)
  {
    while(olgec[oit] == 0)
      oit++;
    if(oit > iit)
    {
      for(char last = 25; last>=0; last--)
      {
        if(olgec[last])
        {
         ans[r] = last + 'a';
         olgec[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = oit + 'a';
      olgec[oit]--;
      l++;
    }
    total ++;
    if(total == n)
      break;

    while(igorc[iit] == 0)
      iit--;

    if(oit > iit)
    {
      for(char last = 0; last<=25; last++)
      {
        if(igorc[last])
        {
         ans[r] = last + 'a';
         igorc[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = iit + 'a';
      igorc[iit]--;
      l++;
    }

    total++;
  }

  cout << ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<int> olgec(26,0);
  vector<int> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  oit = static_cast<char>(25);
  for(int i=0; i<(n+1)/2;)
  {
    while(!olgec[oit])
    {
      oit--;
    }
    int temp = i + min(olgec[oit], (n+1)/2 - i);
    olgec[oit] -= min(olgec[oit], (n+1)/2 - i);
    i = temp;
  }

  iit = static_cast<char>(0);
  for(int i=0; i<(n)/2;)
  {
    while(!igorc[iit])
    {
      iit++;
    }
    int temp = i + min(igorc[iit], (n)/2 - i);
    igorc[iit] -= min(igorc[iit], (n)/2 - i);
    i = temp;
  }

  int l = 0;
  int r = n-1;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.assign(n, '0');
  int total = 0;
  while(total < n)
  {
    while(olgec[oit] == 0)
      oit++;
    if(oit > iit)
    {
      for(char last = 25; last>=0; last--)
      {
        if(olgec[last])
        {
         ans[r] = last + 'a';
         olgec[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = oit + 'a';
      olgec[oit]--;
      l++;
    }
    total ++;
    if(total == n)
      break;

    while(igorc[iit] == 0)
      iit--;

    if(oit > iit)
    {
      for(char last = 0; last<=25; last++)
      {
        if(igorc[last])
        {
         ans[r] = last + 'a';
         igorc[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = iit + 'a';
      igorc[iit]--;
      l++;
    }

    total++;
  }

  cout << ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<char> olgec(26,0);
  vector<char> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.resize(n);
  for(int i=0; i<n; )
  {
    while(olgec[oit] == 0)
      oit++;
    ans[i] = oit + 'a';
    olgec[oit]--;
    while(igorc[iit] == 0)
      iit--;
    igorc[iit]--;
    ans[i+1] = iit + 'a';
    i+=2;
  }

  cout << ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<int> olgec(26,0);
  vector<int> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  oit = static_cast<char>(25);
  for(int i=0; i<(n)/2;)
  {
    while(!olgec[oit])
    {
      oit--;
    }
    int temp = i + min(olgec[oit], (n)/2 - i);
    olgec[oit] -= min(olgec[oit], (n)/2 - i);
    i = temp;
    //cerr << i<<endl;
  }
//cerr<<"---"<<endl;
//cerr << olgec<<endl;
  iit = static_cast<char>(0);
  for(int i=0; i<(n+1)/2;)
  {
    while(!igorc[iit])
    {
      iit++;
    }
    int temp = i + min(igorc[iit], (n+1)/2 - i);
    igorc[iit] -= min(igorc[iit], (n+1)/2 - i);
    i = temp;
  }

  int l = 0;
  int r = n-1;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.assign(n, '0');
  int total = 0;
  while(total < n)
  {
    while(olgec[oit] == 0)
      oit++;

    while(igorc[iit] == 0)
      iit--;

    if(oit >= iit)
    {
      for(char last = 25; last>=0; last--)
      {
        if(olgec[last])
        {
         ans[r] = last + 'a';
         olgec[last]--;
          r--;
          //cerr<<"hh "<<r <<endl;
          break;
        }
      }
      //cerr <<"HOW"<<endl;
    }
    else
    {
      ans[l] = oit + 'a';
      olgec[oit]--;
      l++;

      //cout <<" llllll "<<l<<endl;
    }
    total++;
    if(total == n)
    {
      //cerr<<"boom"<<endl;
      break;
    }

        while(igorc[iit] == 0)
            iit--;
        while(olgec[oit] == 0)
      oit++;

    if(oit >= iit)
    {
      for(char last = 0; last<=25; last++)
      {
        if(igorc[last])
        {
         ans[r] = last + 'a';
         igorc[last]--;
          r--;
        //            cerr<<"hha "<<r <<endl;
          break;
        }
      }
    }
    else
    {
      ans[l] = iit + 'a';
      igorc[iit]--;
      l++;
      //cout <<" lll "<<l<<endl;
    }

    total++;
  }

  //cout <<total<<endl;
  //cout <<"  r  l "<<r<<"  "<<r<<endl;
  cout << ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<int> olgec(26,0);
  vector<int> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  oit = static_cast<char>(25);
  for(int i=0; i<(n)/2;)
  {
    while(!olgec[oit])
    {
      oit--;
    }
    int temp = i + min(olgec[oit], (n)/2 - i);
    olgec[oit] -= min(olgec[oit], (n)/2 - i);
    i = temp;
  //  cerr << i<<endl;
  }
//cerr<<"---"<<endl;
//cerr << olgec<<endl;
  iit = static_cast<char>(0);
  for(int i=0; i<(n+1)/2;)
  {
    while(!igorc[iit])
    {
      iit++;
    }
    int temp = i + min(igorc[iit], (n+1)/2 - i);
    igorc[iit] -= min(igorc[iit], (n+1)/2 - i);
    i = temp;
  }

  int l = 0;
  int r = n-1;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.assign(n, '0');
  int total = 0;
  while(total < n)
  {
    while(olgec[oit] == 0)
      oit++;
    if(oit > iit)
    {
      for(char last = 25; last>=0; last--)
      {
        if(olgec[last])
        {
         ans[r] = last + 'a';
         olgec[last]--;
          r--;
    //      cerr<<"hh "<<r <<endl;
          break;
        }
      }
      //cerr <<"HOW"<<endl;
    }
    else
    {
      ans[l] = oit + 'a';
      olgec[oit]--;
      l++;

      //cout <<" llllll "<<l<<endl;
    }
    total++;
    if(total == n)
    {
      //cerr<<"boom"<<endl;
      break;
    }
    while(igorc[iit] == 0)
      iit--;

    if(oit > iit)
    {
      for(char last = 0; last<=25; last++)
      {
        if(igorc[last])
        {
         ans[r] = last + 'a';
         igorc[last]--;
          r--;
        //            cerr<<"hha "<<r <<endl;
          break;
        }
      }
    }
    else
    {
      ans[l] = iit + 'a';
      igorc[iit]--;
      l++;
      //cout <<" lll "<<l<<endl;
    }

    total++;
  }

  //cout <<total<<endl;
  //cout <<"  r  l "<<r<<"  "<<r<<endl;
  cout << ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<char> olgec(26,0);
  vector<char> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  int l = 0;
  int r = n-1;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.assign(n, '0');
  int total = 0;
  while(total < n)
  {
    while(olgec[oit] == 0)
      oit++;
    if(oit >= iit)
    {
      for(char last = 25; last>=0; last--)
      {
        if(olgec[last])
        {
         ans[r] = last + 'a';
         olgec[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = oit + 'a';
      olgec[oit]--;
      l++;
    }
    total ++;
    if(total == n)
      break;
    while(olgec[oit] == 0)
      oit++;

    while(igorc[iit] == 0)
      iit--;

      ans[l] = iit + 'a';
      igorc[iit]--;
      l++;

    total++;
  }

  cout << ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<int> olgec(26,0);
  vector<int> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  oit = static_cast<char>(25);
  for(int i=0; i<(n+1)/2;)
  {
    while(!olgec[oit])
    {
      oit--;
    }
    int temp = i + min(olgec[oit], (n+1)/2 - i));
    olgec[oit] -= min(olgec[oit], (n+1)/2 - i));
    i = temp;
  }

  iit = static_cast<char>(0);
  for(int i=0; i<(n)/2;)
  {
    while(!igorc[iit])
    {
      iit++;
    }
    int temp = i + min(igorc[iit], (n)/2 - i));
    igorc[iit] -= min(igorc[iit], (n)/2 - i));
    i = temp;
  }

  int l = 0;
  int r = n-1;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.assign(n, '0');
  int total = 0;
  while(total < n)
  {
    while(olgec[oit] == 0)
      oit++;
    if(oit > iit)
    {
      for(char last = 25; last>=0; last--)
      {
        if(olgec[last])
        {
         ans[r] = last + 'a';
         olgec[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = oit + 'a';
      olgec[oit]--;
      l++;
    }
    total ++;
    if(total == n)
      break;

    while(igorc[iit] == 0)
      iit--;

    if(oit > iit)
    {
      for(char last = 0; last<=25; last++)
      {
        if(igorc[last])
        {
         ans[r] = last + 'a';
         igorc[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = iit + 'a';
      igorc[iit]--;
      l++;
    }

    total++;
  }

  cout << ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<char> olgec(26,0);
  vector<char> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  int l = 0;
  int r = n-1;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.assign(n, '0');
  int total = 0;
  while(total < n)
  {
    while(olgec[oit] == 0)
      oit++;
    if(oit >= iit)
    {
      for(char last = 25; last>=0; last--)
      {
        if(olgec[last])
        {
         ans[r] = last + 'a';
         olgec[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = oit + 'a';
      olgec[oit]--;
      l++;
    }
    total ++;
    if(total == n)
      break;
    while(olgec[oit] == 0)
      oit++;

    while(igorc[iit] == 0)
      iit--;

    if(oit >= iit)
    {
      for(char last = 0; last<=25; last++)
      {
        if(igorc[last])
        {
         ans[r] = last + 'a';
         igorc[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = iit + 'a';
      igorc[iit]--;
      l++;
    }

    total++;
  }

  cout << ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<char> olgec(26,0);
  vector<char> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  int l = 0;
  int r = n-1;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.assign(n, '0');
  int total = 0;
  while(total < n)
  {
    while(olgec[oit] == 0)
      oit++;
    if(oit >= iit && total + 1 < n )
    {
      for(char last = 25; last>=0; last--)
      {
        if(olgec[last])
        {
         ans[r] = last + 'a';
         olgec[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = oit + 'a';
      olgec[oit]--;
      l++;
    }
    total ++;
    if(total == n)
      break;
    while(olgec[oit] == 0)
      oit++;

    while(igorc[iit] == 0)
      iit--;

    if(oit >= iit && total + 1 < n)
    {
      for(char last = 0; last<=25; last++)
      {
        if(igorc[last])
        {
         ans[r] = last + 'a';
         igorc[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = iit + 'a';
      igorc[iit]--;
      l++;
    }

    total++;
  }

  cout << ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<<(ostream& out, vector<T>& cont)
{
  out << "{ ";
  for(auto& it : cont)
  {
    out << it << ", ";
  }
  out <<" }";
  return out;
}

int main()
{
  ios_base::sync_with_stdio(false);
  string oleg;
  string igor;
  getline(cin, oleg);
  getline(cin, igor);
  int n = oleg.size();
  vector<char> olgec(26,0);
  vector<char> igorc(26,0);
  for(int i=0; i<n ; ++i)
  {
    olgec[oleg[i] - 'a']++;
    igorc[igor[i] - 'a']++;
  }

  char oit, iit;
  int l = 0;
  int r = n-1;
  oit = 0;
  iit = static_cast<char>(25);
  string ans;
  ans.assign(n, '0');
  int total = 0;
  while(total < n)
  {
    while(olgec[oit] == 0)
      oit++;
    if(oit >= iit)
    {
      for(char last = 25; last>=0; last--)
      {
        if(olgec[last])
        {
         ans[r] = last + 'a';
         olgec[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = oit + 'a';
      olgec[oit]--;
      l++;
    }
    total ++;
    if(total == n)
      break;

    while(igorc[iit] == 0)
      iit--;

    if(oit >= iit)
    {
      for(char last = 0; last<=25; last++)
      {
        if(igorc[last])
        {
         ans[r] = last + 'a';
         igorc[last]--;
          r--;
          break;
        }
      }
    }
    else
    {
      ans[l] = iit + 'a';
      igorc[iit]--;
      l++;
    }

    total++;
  }

  cout << ans<<endl;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    a.erase( ((n+1)/2) , n ) ;
    b.erase(  (n/2) , n ) ;
    string ans , anss ;
    for (int i = 0 ; i < n ; i++ )
    {
        if (i%2==0)
        {
            if (a[c1] <= b[c2] )
            {
              //cout << a[c1] ;
              ans+=a[c1] ;
              c1 ++ ;
            }
            else
            {
                //cout << a[a.size()-1] ;
                anss =a[a.size()-1] + anss ;
                a.erase(a.size()-1) ;
            }
        }
        else
        {
            if (a[c1] <= b[c2] )
            {
              //cout << b[c2] ;
              ans+=b[c2] ;
              c2++ ;
            }
            else
            {
                //cout << b[b.size()-1] ;
                anss = b[b.size()-1] + anss ;
                b.erase(b.size()-1) ;
            }
        }
    }
    cout << ans+anss << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    int en1 = ((n+1)/2)-1, en2 = (n/2)-1  ;
    string ans , anss ;
    for (int i = 0 ; i < n ; i++ )
    {
        if (i%2==0)
        {
            if (a[c1] < b[c2] )
            {
              //cout << a[c1] ;
              ans+=a[c1] ;
              c1 ++ ;
            }
            else
            {
                //cout << a[a.size()-1] ;
                anss =a[en1] + anss ;
                en1-- ;
            }
        }
        else
        {
            if (a[c1] < b[c2] )
            {
              //cout << b[c2] ;
              ans+=b[c2] ;
              c2++ ;
            }
            else
            {
                //cout << b[b.size()-1] ;
                anss = b[en2] + anss ;
                en2-- ;
            }
        }
    }
    cout << ans+anss << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    a.erase( ((n+1)/2) , n ) ;
    b.erase(  (n/2) , n ) ;
    string ans , anss ;
    for (int i = 0 ; i < n ; i++ )
    {
        if (i%2==0)
        {
            if (a[c1] <= b[c2] )
            {
              //cout << a[c1] ;
              ans = a[c1] + ans ;
              c1 ++ ;
            }
            else
            {
                //cout << a[a.size()-1] ;
                anss =a[a.size()-1] + anss ;
                a.erase(a.size()-1) ;
            }
        }
        else
        {
            if (a[c1] <= b[c2] )
            {
              //cout << b[c2] ;
              ans = ans + b[c2] ;
              c2++ ;
            }
            else
            {
                //cout << b[b.size()-1] ;
                anss = b[b.size()-1] + anss ;
                b.erase(b.size()-1) ;
            }
        }
    }
    cout << ans+anss << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    for (int i = 0 ; i<n ;i++ )
    {
        if (i%2==0)
        {
            cout << a[c1] ;
            c1++  ;
        }
        else
        {
            cout <<b[c2] ;
            c2++;
        }
    }
    cout << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    int en1 = ((n+1)/2) , en2 = (n/2)  ;
    string ans , anss ;
    for (int i = 0 ; i < n ; i++ )
    {
        if (i%2==0)
        {
            if (a[c1] < b[c2] )
            {
              //cout << a[c1] ;
              ans+=a[c1] ;
              c1 ++ ;
            }
            else
            {
                //cout << a[a.size()-1] ;
                anss =a[en1] + anss ;
                en1-- ;
            }
        }
        else
        {
            if (a[c1] < b[c2] )
            {
              //cout << b[c2] ;
              ans+=b[c2] ;
              c2++ ;
            }
            else
            {
                //cout << b[b.size()-1] ;
                anss = b[en2] + anss ;
                en2-- ;
            }
        }
    }
    cout << ans+anss << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    a.erase( ((n+1)/2) , n ) ;
    b.erase(  (n/2) , n ) ;
    string ans , anss ;
    for (int i = 0 ; i < n ; i++ )
    {
        if (i%2==0)
        {
            if (a[c1] < b[c2] )
            {
              //cout << a[c1] ;
              ans+=a[c1] ;
              c1 ++ ;
            }
            else
            {
                //cout << a[a.size()-1] ;
                anss =a[a.size()-1] + anss ;
                a.erase(a.size()-1) ;
            }
        }
        else
        {
            if (a[c1] < b[c2] )
            {
              //cout << b[c2] ;
              ans+=b[c2] ;
              c2++ ;
            }
            else
            {
                //cout << b[b.size()-1] ;
                anss = b[b.size()-1] + anss ;
                b.erase(b.size()-1) ;
            }
        }
    }
    cout << ans+anss << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    for (int i = 0 ; i<n ; i ++ )
    {
        if (i%2==0)
        {
            if (a[c1] > b[c2] )
            {
                cout << b[b.size()-1] << a[c1]  ;
                c1++ ;
                b.erase(b.size()-1) ;
                i++ ;
            }
            else
            {
                cout << a[c1]  ;
                c1 ++ ;
            }
        }
        else
        {
                cout << b[c2]  ;
                c2++ ;
        }
    }
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    a.erase( ((n+1)/2) , n ) ;
    b.erase(  (n/2) , n ) ;
    int en1 = a.size()-1 , en2 = b.size()-1 ;
    string ans , anss ;
    for (int i = 0 ; i < n ; i++ )
    {
        if (i%2==0)
        {
            if (a[c1] < b[c2] )
            {
              //cout << a[c1] ;
              ans+=a[c1] ;
              c1 ++ ;
            }
            else
            {
                //cout << a[a.size()-1] ;
                anss =a[en1] + anss ;
                en1-- ;
            }
        }
        else
        {
            if (a[c1] < b[c2] )
            {
              //cout << b[c2] ;
              ans+=b[c2] ;
              c2++ ;
            }
            else
            {
                //cout << b[b.size()-1] ;
                anss = b[en2] + anss ;
                en2-- ;
            }
        }
    }
    cout << ans+anss << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    int en1 = ((n+1)/2)-1, en2 = (n/2)-1  ;
    string ans , anss ;
    for (int i = 0 ; i < n ; i++ )
    {
        if (i%2==0)
        {
            if (a[c1] < b[c2] )
            {
              //cout << a[c1] ;
              ans+=a[c1] ;
              c1 ++ ;
            }
            else
            {
                //cout << a[a.size()-1] ;
                string t ;
                t += a[en1] ;
                t += anss ;
                anss = t  ;
                en1-- ;
            }
        }
        else
        {
            if (a[c1] < b[c2] )
            {
              //cout << b[c2] ;
              ans+=b[c2] ;
              c2++ ;
            }
            else
            {
                //cout << b[b.size()-1] ;
                string t;
                t +=b[en2] ;
                t +=anss ;
                anss = t ;
                en2-- ;
            }
        }
    }
    cout << ans+anss << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    a.erase( ((n+1)/2) , n ) ;
    b.erase(  (n/2) , n ) ;
    for (int i = 0 ; i < n ; i++ )
    {
        if (i%2==0)
        {
            if (a[c1] <= b[c2] )
            {
              cout << a[c1] ;
              c1 ++ ;
            }
            else
            {
                cout << a[a.size()-1] ;
                a.erase(a.size()-1) ;
            }
        }
        else
        {
            if (a[c1] <= b[c2] )
            {
              cout << b[c2] ;
              c2++ ;
            }
            else
            {
                cout << b[b.size()-1] ;
                b.erase(b.size()-1) ;
            }
        }
    }
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    int en1 = ((n+1)/2)-1, en2 = (n/2)-1  ;
    string ans , anss ;
    for (int i = 0 ; i < n ; i++ )
    {
        if (i%2==0)
        {
            if (a[c1] < b[c2] )
            {
              //cout << a[c1] ;
              ans+=a[c1] ;
              c1 ++ ;
            }
            else
            {
                //cout << a[a.size()-1] ;
                anss +=a[en1] ;
                en1-- ;
            }
        }
        else
        {
            if (a[c1] < b[c2] )
            {
              //cout << b[c2] ;
              ans+=b[c2] ;
              c2++ ;
            }
            else
            {
                //cout << b[b.size()-1] ;
                anss +=b[en2];
                en2-- ;
            }
        }
    }
    reverse(anss.begin() , anss.end() ) ;
    cout << ans+anss << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    for (int i = 0 ; i<n ; i ++ )
    {
        if (i%2==0)
        {
            if (a[c1] > b[c2] && i!=n-1)
            {
                cout << i ;
                cout << b[c2] << a[c1]  ;
                c1++ ;
                c2++ ;
                i++ ;
            }
            else
            {
                cout << a[c1]  ;
                c1 ++ ;
            }
        }
        else
        {
                cout << b[c2]  ;
                c2++ ;
        }
    }
    return 0 ;
}


#include<bits/stdc++.h>
#define pb push_back
using namespace std ;
deque < char > de ;
int main ()
{
    string a , b ;
    cin >> a >> b ;
    sort (a.begin() , a.end() ) ;
    sort (b.begin() , b.end() ) ;
    reverse(b.begin() , b.end());
    int n = a.size() ;
    int c1 = 0, c2 = 0 ;
    int en1 = ((n+1)/2)-1, en2 = (n/2)-1  ;
    string ans , anss ;
    for (int i = 0 ; i < n ; i++ )
    {
        if (i%2==0)
        {
            if (a[c1] < b[c2] )
            {
              //cout << a[c1] ;
              //ans+=a[c1] ;
              de.push_back(a[c1]) ;
              c1 ++ ;
            }
            else
            {
                //cout << a[a.size()-1] ;
                de.push_front(a[en1]);
                //anss =a[en1] + anss ;
                en1-- ;
            }
        }
        else
        {
            if (a[c1] < b[c2] )
            {
              //cout << b[c2] ;
              //ans+=b[c2] ;
              de.push_back(b[c2]) ;
              c2++ ;
            }
            else
            {
                //cout << b[b.size()-1] ;
                //anss = b[en2] + anss ;
                de.push_front(b[en2]) ;
                en2-- ;
            }
        }
    }
    for (int i = 0 ;i<n ; i++)
        cout << de[i] ;
        cout << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool compare(char a,char b){
if(a>=b)
	return true;
else return false;

}
int main(){ ll int cindex=0,bindex=0,aindex=0;
char a[300009];
char b[300009];
char c[300009];
gets(a);
gets(b);
ll int n=strlen(a);
static int  m[300009];
sort(b,b+n,compare);
sort(a,a+n);
for(int i=0;i<n;i++){
if(m[cindex]==1)
cindex++;
if(cindex==n-1){
if(i%2==0)
c[n-1]=a[aindex];
else
c[n-1]=b[bindex];
}
if(i%2==0){
if(a[aindex]<b[bindex]){
c[cindex]=a[aindex];
aindex++;
m[cindex]=1;
cindex++;

}
else
{ cindex+=1;
c[cindex]=a[aindex];
aindex++;
m[cindex]=1;
cindex-=1;
}
}

else
{ c[cindex]=b[bindex];
m[cindex]=1;
cindex++;
bindex++;

}
}

puts(c);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool compare(char a,char b){
if(a>=b)
	return true;
else return false;

}
int main(){ ll int cindex=0,bindex=0,aindex=0;
char a[300009];
char b[300009];
char c[300009];
gets(a);
gets(b);
ll int n=strlen(a);
static int  m[300009];
sort(b,b+n,compare);
sort(a,a+n);
for(int i=0;i<n;i++){
if(m[cindex]==1)
cindex++;
if(cindex==n-1){
if(i%2==0)
c[n-1]=a[aindex];
else
c[n-1]=b[bindex];
}
if(i%2==0){
if(a[aindex]<b[bindex]){
c[cindex]=a[aindex];
aindex++;

cindex++;

}
else
{ cindex+=1;
c[cindex]=a[aindex];
aindex++;
m[cindex]=1;
cindex-=1;
}
}

else
{ c[cindex]=b[bindex];

cindex++;
bindex++;

}
}

puts(c);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool compare(char a,char b){
if(a>=b)
	return true;
else return false;

}
int main(){ ll int cindex=0,bindex=0,aindex=0;
char a[300009];
char b[300009];
char c[300009];
gets(a);
gets(b);
ll int n=strlen(a);
sort(b,b+n,compare);
sort(a,a+n);
for(int i=0;i<n;i++){
if(i%2==0){

c[cindex]=	a[aindex];
aindex++;
cindex++;
}
else
{ c[cindex]=b[bindex];
	cindex++;
	bindex++;
}

}
puts(c);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool compare(char a,char b)
{
    if(a>=b)
        return true;
    else return false;

}
int main()
{
    ll int cindex=0,bindex=0,aindex=0;
    char a[300009];
    char b[300009];
    char c[300009];
    gets(a);
    gets(b);
    ll int n=strlen(a);
    static int  m[300009];
    sort(b,b+n,compare);
    sort(a,a+n);
    for(int i=0; i<n; i++)
    {
        if(m[cindex]==1)
            cindex++;
        if(cindex==n-1)
        {
            if(i%2==0)
                c[n-1]=a[aindex];
            else
                c[n-1]=b[bindex];

        }
        if(i%2==0)
        {
            if(a[aindex]<b[bindex])
            {
                c[cindex]=a[aindex];
                aindex++;

                cindex++;

            }
            else
            {
                cindex+=1;
                c[cindex]=a[aindex];
                aindex++;
                m[cindex]=1;
                cindex-=1;

            }
        }

        else
        {
            c[cindex]=b[bindex];

            cindex++;
            bindex++;

        }
    }

    for(int i=0; i<n; i++)
    {
        cout<<c[i];
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool compare(char a,char b){
if(a>=b)
	return true;
else return false;

}
int main(){ ll int cindex=0,bindex=0,aindex=0;
char a[300009];
char b[300009];
char c[300009];
gets(a);
gets(b);
ll int n=strlen(a);
static int  m[300009];
sort(b,b+n,compare);
sort(a,a+n);
for(int i=0;i<n;i++){
if(m[cindex]==1)
cindex++;
if(cindex==n-1){
if(i%2==0)
c[n-1]=a[aindex];
else
c[n-1]=b[bindex];
continue;
}
if(i%2==0){
if(a[aindex]<b[bindex]){
c[cindex]=a[aindex];
aindex++;

cindex++;
continue;
}
else
{ cindex+=1;
c[cindex]=a[aindex];
aindex++;
m[cindex]=1;
cindex-=1;
continue;
}
}

else
{ c[cindex]=b[bindex];

cindex++;
bindex++;
continue;

}
}

puts(c);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool compare(char a,char b)
{
    if(a>b)
        return true;
    else
        return false;

}
int main()
{
    unsigned int aindex=0,bindex=0,cindex=0;
    static int marked[300009];
    unsigned int sizea,sizeb;
    char a[300009];
    char b[300009];
    char c[300009];
    gets(a);
    gets(b);
    unsigned int n=strlen(a);
    if(n%2==0)
    {
        sizea=n/2;
        sizeb=n/2;
    }
    else
    {
        sizeb=(n-1)/2;
        sizea=sizeb+1;
    }
    sort(a,a+n);
    sort(b,b+n,compare);
    unsigned last=n-1;
    unsigned first=0;
    for(int i=0; i<n; ++i)
    {
        if(i==n-1)
        {
            if(i%2==0)
            {

                c[cindex]=a[aindex];
                aindex++;
                cindex++;
                break;

            }
            else
            {

                c[cindex]=b[bindex];
                cindex++;
                bindex++;
                break;

            }

        }

        if(i%2==0)
        {
            if(a[aindex]>=b[bindex])
            {
                c[last]=a[sizea-1];
                marked[last]=1;
                sizea--;
                last--;

            }
            else
            {

                        c[cindex]=a[aindex];
                        marked[cindex]=1;
                        aindex++;
                        cindex++;

            }
        }

        else
        {
            if(b[bindex]<=a[aindex])
            {
                c[last]=b[sizeb-1];
                marked[last]=1;
                sizeb--;
                last--;

            }
            else
            {

                    if(marked[i]!=1)
                    {
                        c[cindex]=b[bindex];
                        marked[cindex]=1;
                        bindex++;
                        cindex++;

                    }

            }
        }

    }
    for(int j=0; j<n; j++)
        cout<<c[j];
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool compare(char a,char b)
{
    if(a>b)
        return true;
    else
        return false;

}
int main()
{
    unsigned int aindex=0,bindex=0,cindex=0;
    static int marked[300009];
    unsigned int sizea,sizeb;
    char a[300009];
    char b[300009];
    char c[300009];
    gets(a);
    gets(b);
    unsigned int n=strlen(a);
    if(n%2==0)
    {
        sizea=n/2;
        sizeb=n/2;
    }
    else
    {
        sizeb=(n-1)/2;
        sizea=sizeb+1;
    }
    sort(a,a+n);
    sort(b,b+n,compare);
    unsigned last=n-1;
    unsigned first=0;
    for(int i=0; i<n; ++i)
    {
        if(i==n-1)
        {
            if(i%2==0)
            {
                for(int i=0; i<n; i++)
                {
                    if(marked[i]!=1)
                    {
                        c[i]=a[aindex];
                       break;
                    }
                }
            }
            else
            {
                for(int i=0; i<n; i++)
                {
                    if(marked[i]!=1)
                    {
                        c[i]=b[bindex];

                       break;
                    }
                }

            }

        }

        if(i%2==0)
        {
            if(a[aindex]>=b[bindex])
            {
                c[last]=a[sizea-1];
                marked[last]=1;
                sizea--;
                last--;

            }
            else
            {
                for(int i=0; i<n; i++)
                {
                    if(marked[i]!=1)
                    {
                        c[i]=a[aindex];
                        marked[i]=1;
                        aindex++;
                        break;
                    }
                }
            }
        }

        else
        {
            if(b[bindex]<=a[aindex])
            {
                c[last]=b[sizeb-1];
                marked[last]=1;
                sizeb--;
                last--;

            }
            else
            {
                for(int i=0; i<n; i++)
                {
                    if(marked[i]!=1)
                    {
                        c[i]=b[bindex];
                        marked[i]=1;
                        bindex++;
                        break;
                    }
                }

            }
        }

    }
    puts(c);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool compare(char a,char b){
if(a>=b)
	return true;
else return false;

}
int main(){ ll int cindex=0,bindex=0,aindex=0;
char a[300009];
char b[300009];
char c[300009];
gets(a);
gets(b);
ll int n=strlen(a);
sort(b,b+n,compare);
sort(a,a+n);

for(int i=0;i<n;i++){
if(i%2==0){

c[cindex]=	a[aindex];
aindex++;
cindex++;
}
else
{ c[cindex]=b[bindex];
	cindex++;
	bindex++;
}

}
puts(c);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool compare(char a,char b)
{
    if(a>b)
        return true;
    else
        return false;

}
int main()
{
    unsigned int aindex=0,bindex=0,cindex=0;
    static int marked[300009];
    unsigned int sizea,sizeb;
    char a[300009];
    char b[300009];
    char c[300009];
    gets(a);
    gets(b);
    unsigned int n=strlen(a);
    if(n%2==0)
    {
        sizea=n/2;
        sizeb=n/2;
    }
    else
    {
        sizeb=(n-1)/2;
        sizea=sizeb+1;
    }
    sort(a,a+n);
    sort(b,b+n,compare);
    unsigned last=n-1;
    unsigned first=0;
    for(int i=0; i<n; ++i)
    {
        if(i==n-1)
        {
            if(i%2==0)
            {
                for(int i=0; i<n; i++)
                {
                    if(marked[i]!=1)
                    {
                        c[i]=a[aindex];
                       break;
                    }
                }
            }
            else
            {
                for(int i=0; i<n; i++)
                {
                    if(marked[i]!=1)
                    {
                        c[i]=b[bindex];

                       break;
                    }
                }

            }

        }

        if(i%2==0)
        {
            if(a[aindex]>=b[bindex])
            {
                c[last]=a[sizea-1];
                marked[last]=1;
                sizea--;
                last--;

            }
            else
            {
                for(int i=0; i<n; i++)
                {
                    if(marked[i]!=1)
                    {
                        c[i]=a[aindex];
                        marked[i]=1;
                        aindex++;
                        break;
                    }
                }
            }
        }

        else
        {
            if(b[bindex]<=a[aindex])
            {
                c[last]=b[sizeb-1];
                marked[last]=1;
                sizeb--;
                last--;

            }
            else
            {
                for(int i=0; i<n; i++)
                {
                    if(marked[i]!=1)
                    {
                        c[i]=b[bindex];
                        marked[i]=1;
                        bindex++;
                        break;
                    }
                }

            }
        }

    }
    for(int j=0;j<n;j++)
    cout<<c[j];
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    int n = sz(a);
    vi dp1(26, 0), dp2(26, 0);
    vector <char> ans(n);
    forn(i, 0, n)
    {
        dp1[a[i] - 'a']++;
        dp2[b[i] - 'a']++;
    }
    a = ""; b = "";
    forn(i, 0, 26)
    {
        int val = dp1[i];
        forn(j, 0, val) a += char(i + 'a');
        val = dp2[i];
        forn(j, 0, val) b += char(i + 'a');
    }
    deque <char> mass1, mass2;
    forn(i, 0, n)
    {
        mass1.pb(a[i]);
        mass2.pb(b[i]);
    }
    deque <int> pos; forn(i, 0, n) pos.pb(i);
    forn(i, 0, n)
    {
        if (i & 1)
        {
            char c = mass2.back();
            if (c > mass1.front())
            {
                ans[pos.back()] = mass2.front();
                pos.pop_back();
                mass2.pop_front();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass2.pop_back();
            }
        }
        else
        {
            char c = mass1.front();
            if (c < mass2.back())
            {
                ans[pos.back()] = mass1.back();
                pos.pop_back();
                mass1.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass1.pop_front();
            }
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    int n = sz(a);
    vi dp1(26, 0), dp2(26, 0);
    vector <char> ans(n);
    forn(i, 0, n)
    {
        dp1[a[i] - 'a']++;
        dp2[b[i] - 'a']++;
    }
    a = ""; b = "";
    forn(i, 0, 26)
    {
        int val = dp1[i];
        forn(j, 0, val) a += char(i + 'a');
        val = dp2[i];
        forn(j, 0, val) b += char(i + 'a');
    }
    deque <char> mass1, mass2;
    forn(i, 0, n)
    {
        mass1.pb(a[i]);
        mass2.pb(b[i]);
    }
    deque <int> pos; forn(i, 0, n) pos.pb(i);
    forn(i, 0, n)
    {
        if (i & 1 == 0)
        {
            char c = mass2.back();
            if (c >= mass1.front())
            {
                ans[pos.back()] = mass2.front();
                pos.pop_back();
                mass2.pop_front();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass2.pop_back();
            }
        }
        else
        {
            char c = mass1.front();
            if (c <= mass2.back())
            {
                ans[pos.back()] = mass1.back();
                pos.pop_back();
                mass1.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass1.pop_front();
            }
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    int n = sz(a);
    vi dp1(26, 0), dp2(26, 0);
    vector <char> ans(n);
    forn(i, 0, n)
    {
        dp1[a[i] - 'a']++;
        dp2[b[i] - 'a']++;
    }
    a = ""; b = "";
    forn(i, 0, 26)
    {
        int val = dp1[i];
        forn(j, 0, val) a += char(i + 'a');
        val = dp2[i];
        forn(j, 0, val) b += char(i + 'a');
    }
    deque <char> mass1, mass2;
    forn(i, 0, n)
    {
        mass1.pb(a[i]);
        mass2.pb(b[i]);
    }
    deque <int> pos; forn(i, 0, n) pos.pb(i);
    forn(i, 0, n)
    {
        if (i & 1)
        {
            char c = mass2.back();
            if (c < mass1.front())
            {
                ans[pos.back()] = mass2.front();
                pos.pop_back();
                mass2.pop_front();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass2.pop_back();
            }
        }
        else
        {
            char c = mass1.front();
            if (c > mass2.back())
            {
                ans[pos.back()] = mass1.back();
                pos.pop_back();
                mass1.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass1.pop_front();
            }
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    sort(all(a)); sort(all(b)); reverse(all(b));
    int n = sz(a);
    a = a.substr(0, (n + 1) / 2);
    b = b.substr(0, n / 2);
    reverse(all(b));
    int l = 0, r = n - 1, l1 = 0, l2 = 0, r1 = sz(a) - 1, r2 = sz(b) - 1;
    char ans[n];
    forn(i, 0, n)
    {
        if (l1 > r1) {ans[l] = b[l2]; continue;}
        if (l2 > r2) {ans[l] = a[l1]; continue;}
        if (i & 1)
        {
            if (b[r2] <= a[l1]) ans[r--] = b[l2++];
            else ans[l++] = b[r2--];
        }
        else
        {
            if (a[l1] >= b[r2]) ans[r--] = a[r2--];
            else ans[l++] = a[l1++];
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    int n = sz(a);
    vi dp1(26, 0), dp2(26, 0);
    vector <char> ans(n);
    forn(i, 0, n)
    {
        dp1[a[i] - 'a']++;
        dp2[b[i] - 'a']++;
    }
    a = ""; b = "";
    forn(i, 0, 26)
    {
        int val = dp1[i];
        forn(j, 0, val) a += char(i + 'a');
        val = dp2[i];
        forn(j, 0, val) b += char(i + 'a');
    }
    deque <char> mass1, mass2;
    forn(i, 0, n)
    {
        mass1.pb(a[i]);
        mass2.pb(b[i]);
    }
    deque <int> pos; forn(i, 0, n) pos.pb(i);
    forn(i, 0, n)
    {
        if (i & 1)
        {
            char c = mass2.back();
            if (c < mass1.front())
            {
                ans[pos.back()] = mass2.front();
                pos.pop_back();
                mass2.pop_front();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass2.pop_back();
            }
        }
        else
        {
            char c = mass1.front();
            if (c >= mass2.back())
            {
                ans[pos.back()] = mass1.back();
                pos.pop_back();
                mass1.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass1.pop_front();
            }
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    int n = sz(a);
    vi dp1(26, 0), dp2(26, 0);
    vector <char> ans(n);
    forn(i, 0, n)
    {
        dp1[a[i] - 'a']++;
        dp2[b[i] - 'a']++;
    }
    a = ""; b = "";
    forn(i, 0, 26)
    {
        int val = dp1[i];
        forn(j, 0, val) a += char(i + 'a');
        val = dp2[i];
        forn(j, 0, val) b += char(i + 'a');
    }
    deque <char> mass1, mass2;
    forn(i, 0, n)
    {
        mass1.pb(a[i]);
        mass2.pb(b[i]);
    }
    deque <int> pos; forn(i, 0, n) pos.pb(i);
    forn(i, 0, n)
    {
        if (i & 1)
        {
            char c = mass2.back();
            if (c <= mass1.front())
            {
                ans[pos.back()] = mass2.front();
                pos.pop_back();
                mass2.pop_front();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass2.pop_back();
            }
        }
        else
        {
            char c = mass1.front();
            if (c > mass2.back())
            {
                ans[pos.back()] = mass1.back();
                pos.pop_back();
                mass1.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass1.pop_front();
            }
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    int n = sz(a);
    vi dp1(26, 0), dp2(26, 0);
    vector <char> ans(n);
    forn(i, 0, n)
    {
        dp1[a[i] - 'a']++;
        dp2[b[i] - 'a']++;
    }
    a = ""; b = "";
    forn(i, 0, 26)
    {
        int val = dp1[i];
        forn(j, 0, val) a += char(i + 'a');
        val = dp2[i];
        forn(j, 0, val) b += char(i + 'a');
    }
    deque <char> mass1, mass2;
    forn(i, 0, n)
    {
        mass1.pb(a[i]);
        mass2.pb(b[i]);
    }
    deque <int> pos; forn(i, 0, n) pos.pb(i);
    forn(i, 0, n)
    {
        if (i & 1)
        {
            char c = mass2.back();
            mass2.pop_back();
            if (c < mass1.front())
            {
                ans[pos.back()] = c;
                pos.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
            }
        }
        else
        {
            char c = mass1.front();
            mass1.pop_front();
            if (c > mass2.back())
            {
                ans[pos.back()] = c;
                pos.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
            }
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    sort(all(a)); sort(all(b)); reverse(all(b));
    int n = sz(a);
    a = a.substr(0, (n + 1) / 2);
    b = b.substr(0, n / 2);
    reverse(all(b));
    int l = 0, r = n - 1, l1 = 0, l2 = 0, r1 = sz(a) - 1, r2 = sz(b) - 1;
    char ans[n];
    forn(i, 0, n)
    {
        if (i & 1)
        {
            if (b[r2] <= a[l1]) ans[r--] = b[l2++];
            else ans[l++] = b[r2--];
        }
        else
        {
            if (a[l1] >= b[r2]) ans[r--] = a[r1--];
            else ans[l++] = a[l1++];
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    int n = sz(a);
    vi dp1(26, 0), dp2(26, 0);
    vector <char> ans(n);
    forn(i, 0, n)
    {
        dp1[a[i] - 'a']++;
        dp2[b[i] - 'a']++;
    }
    a = ""; b = "";
    forn(i, 0, 26)
    {
        int val = dp1[i];
        forn(j, 0, val) a += char(i + 'a');
        val = dp2[i];
        forn(j, 0, val) b += char(i + 'a');
    }
    deque <char> mass1, mass2;
    forn(i, 0, n)
    {
        mass1.pb(a[i]);
        mass2.pb(b[i]);
    }
    deque <int> pos; forn(i, 0, n) pos.pb(i);
    forn(i, 0, n)
    {
        if (i & 1 == 0)
        {
            char c = mass2.back();
            if (c <= mass1.front())
            {
                ans[pos.back()] = mass2.front();
                pos.pop_back();
                mass2.pop_front();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass2.pop_back();
            }
        }
        else
        {
            char c = mass1.front();
            if (c > mass2.back())
            {
                ans[pos.back()] = mass1.back();
                pos.pop_back();
                mass1.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass1.pop_front();
            }
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    int n = sz(a);
    vi dp1(26, 0), dp2(26, 0);
    vector <char> ans(n);
    forn(i, 0, n)
    {
        dp1[a[i] - 'a']++;
        dp2[b[i] - 'a']++;
    }
    a = ""; b = "";
    forn(i, 0, 26)
    {
        int val = dp1[i];
        forn(j, 0, val) a += char(i + 'a');
        val = dp2[i];
        forn(j, 0, val) b += char(i + 'a');
    }
    deque <char> mass1, mass2;
    forn(i, 0, n)
    {
        mass1.pb(a[i]);
        mass2.pb(b[i]);
    }
    deque <int> pos; forn(i, 0, n) pos.pb(i);
    forn(i, 0, n)
    {
        if (i & 1)
        {
            char c = mass2.back();
            if (c <= mass1.front())
            {
                ans[pos.back()] = mass2.front();
                pos.pop_back();
                mass2.pop_front();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass2.pop_back();
            }
        }
        else
        {
            char c = mass1.front();
            if (c >= mass2.back())
            {
                ans[pos.back()] = mass1.back();
                pos.pop_back();
                mass1.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass1.pop_front();
            }
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    int n = sz(a);
    vi dp1(26, 0), dp2(26, 0);
    vector <char> ans(n);
    forn(i, 0, n)
    {
        dp1[a[i] - 'a']++;
        dp2[b[i] - 'a']++;
    }
    a = ""; b = "";
    forn(i, 0, 26)
    {
        int val = dp1[i];
        forn(j, 0, val) a += char(i + 'a');
        val = dp2[i];
        forn(j, 0, val) b += char(i + 'a');
    }
    deque <char> mass1, mass2;
    forn(i, 0, n)
    {
        mass1.pb(a[i]);
        mass2.pb(b[i]);
    }
    deque <int> pos; forn(i, 0, n) pos.pb(i);
    forn(i, 0, n)
    {
        if (i & 1 == 0)
        {
            char c = mass2.back();
            if (c <= mass1.back())
            {
                ans[pos.back()] = mass2.front();
                pos.pop_back();
                mass2.pop_front();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass2.pop_back();
            }
        }
        else
        {
            char c = mass1.front();
            if (c >= mass2.front())
            {
                ans[pos.back()] = mass1.back();
                pos.pop_back();
                mass1.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
                mass1.pop_front();
            }
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define int int64_t
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sz(a) ((int) a.size())
#define all(a) a.begin(), a.end()
#define forn(i, j, n) for (int i = j; i < n; ++i)
#define forc(i, n, j) for (int i = n - 1; i >= j; --i)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef pair <double, double> pdd;
typedef pair <bool, bool> pbb;
typedef vector <int> vi;
typedef vector <double> vd;
typedef vector <bool> vb;
typedef vector <string> vs;
typedef vector <pii> vpii;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vpii> vvpii;
typedef vector <vs> vvs;
typedef vector <vd> vvd;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    int n = sz(a);
    vi dp1(26, 0), dp2(26, 0);
    vector <char> ans(n);
    forn(i, 0, n)
    {
        dp1[a[i] - 'a']++;
        dp2[b[i] - 'a']++;
    }
    a = ""; b = "";
    forn(i, 0, 26)
    {
        int val = dp1[i];
        forn(j, 0, val) a += char(i + 'a');
        val = dp2[i];
        forn(j, 0, val) b += char(i + 'a');
    }
    deque <char> mass1, mass2;
    forn(i, 0, n)
    {
        mass1.pb(a[i]);
        mass2.pb(b[i]);
    }
    deque <int> pos; forn(i, 0, n) pos.pb(i);
    forn(i, 0, n)
    {
        if (i & 1)
        {
            char c = mass2.back();
            mass2.pop_back();
            if (c <= mass1.front())
            {
                ans[pos.back()] = c;
                pos.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
            }
        }
        else
        {
            char c = mass1.front();
            mass1.pop_front();
            if (c >= mass2.back())
            {
                ans[pos.back()] = c;
                pos.pop_back();
            }
            else
            {
                ans[pos.front()] = c;
                pos.pop_front();
            }
        }
    }
    forn(i, 0, n) cout << ans[i];
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
long a[26],b[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s;
	cin>>t;
	long n,i,j,k;
	n=s.size();
	char ans[n+1];

	for(i=0;i<n;i++)
		{
		 a[s[i]-'a']++;
		 b[t[i]-'a']++;
		}
	j=0;
	k=25;
	for(i=0;i<n;i++)
	{
		if(i%2==0){

		 while(a[j]==0)
			j++;
		 if(j<k)
		 {
		 	ans[i] =char('a'+j);
		 }
		 a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;

			ans[i] = char('a'+k);
			b[k]--;
		}
	}
	for(i=0;i<n;i++)
		cout<<ans[i];

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
long long a[26],b[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s;
	cin>>t;
	long long n,i,j,k;
	n=s.size();
	char ans[n+1];

	for(i=0;i<n;i++)
		{
		 a[s[i]-'a']++;
		 b[t[i]-'a']++;
		}
	j=0;
	k=25;
	while(b[k]==0)
				k--;
	while(a[j]==0 )
			j++;
	for(i=0;i<n;i++)
	{
		if(i%2==0){

		 if(j<=k)
		 	ans[i] =char('a'+j);
		 else
		 	break;
		 a[j]--;
		 while(a[j]==0)
			j++;
		}
		else
		{
			if(k>=j)
				ans[i] = char('a'+k);
			else
				break;
			b[k]--;
			while(b[k]==0)
				k--;
		}
	}
	long long f=i;
	char x[n+1],y[n+1];
	long aa=0,bb=0;
	char cc;
	for(i;i<n;i++)
	{
		if(i%2==0)
		{
		 	x[aa]=char('a'+j);
		 	aa++;
		 	a[j]--;
		 	while(a[j]==0)
				j++;
		}
		else
		{
			y[bb] = char('a'+k);
			bb++;
			b[k]--;
			while(b[k]==0 )
				k--;
		}
	}
	j=aa-1;
	k=bb-1;
	//cout<<x<<endl;
	//cout<<y<<endl;
	for(i=n-1;i>=f;i--)
	{
		if((f&1)^((n-1-i)&1)==0)
			{ans[i]=x[j];
				j--;}
		else
		{
			ans[i]=y[k];
			k--;
		}
	}

	for(i=0;i<n;i++)
		cout<<ans[i];

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
long a[26],b[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s;
	cin>>t;
	long n,i,j,k;
	n=s.size();
	char ans[n+1];

	for(i=0;i<n;i++)
		{
		 a[s[i]-'a']++;
		 b[t[i]-'a']++;
		}
	j=0;
	k=25;
	for(i=0;i<n;i++)
	{
		if(i%2==0){

		 while(a[j]==0)
			j++;
		 if(j<=k)
		 	ans[i] =char('a'+j);
		 else
		 	break;
		 a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			if(k>j)
				ans[i] = char('a'+k);
			else
				break;
			b[k]--;
		}
	}
	long x=i;
	for(i=n-1;i>=x;i--)
	{
		if(x%2==0 ){
		 if((n-1-i)%2==0)
		  {
			while(a[j]==0)
			j++;
			ans[i]=char('a'+j);
			a[j]--;
		  }
		 else
		  {
			while(b[k]==0)
				k--;
			ans[i]=char('a'+k);
			b[k]--;
		  }
		}
	else
		{
		  if((n-1-i)%2==1)
		  {
		  	while(a[j]==0)
			j++;
			ans[i]=char('a'+j);
			a[j]--;
		  }
		  else
		  {
		  	while(b[k]==0)
				k--;
			ans[i]=char('a'+k);
			b[k]--;
		  }
		}
	}
	for(i=0;i<n;i++)
		cout<<ans[i];

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
long a[26],b[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s;
	cin>>t;
	long n,i,j,k;
	n=s.size();
	char ans[n+1];

	for(i=0;i<n;i++)
		{
		 a[s[i]-'a']++;
		 b[t[i]-'a']++;
		}
	j=0;
	k=25;
	for(i=0;i<n;i++)
	{
		if(i%2==0){

		 while(a[j]==0)
			j++;
		 ans[i] =char('a'+j);
		 a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			ans[i] = char('a'+k);
			b[k]--;
		}
	}
	for(i=0;i<n;i++)
		cout<<ans[i];

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
long a[26],b[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s;
	cin>>t;
	long n,i,j,k;
	n=s.size();
	char ans[n+1];

	for(i=0;i<n;i++)
		{
		 a[s[i]-'a']++;
		 b[t[i]-'a']++;
		}
	j=0;
	k=25;
	while(b[k]==0)
				k--;
	 while(a[j]==0)
			j++;
	for(i=0;i<n;i++)
	{
		if(i%2==0){

		 while(a[j]==0)
			j++;
		 if(j<=k)
		 	ans[i] =char('a'+j);
		 else
		 	break;
		 a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			if(k>=j)
				ans[i] = char('a'+k);
			else
				break;
			b[k]--;
		}
	}
	long x=i;
	for(i=n-1;i>=x;i--)
	{
		if(x%2==0 ){
		 if((n-1-i)%2==0)
		  {
			while(a[j]==0)
			j++;
			ans[i]=char('a'+j);
			a[j]--;
		  }
		 else
		  {
			while(b[k]==0)
				k--;
			ans[i]=char('a'+k);
			b[k]--;
		  }
		}
	else
		{
		  if((n-1-i)%2==1)
		  {
		  	while(a[j]==0)
			j++;
			ans[i]=char('a'+j);
			a[j]--;
		  }
		  else
		  {
		  	while(b[k]==0)
				k--;
			ans[i]=char('a'+k);
			b[k]--;
		  }
		}
	}
	for(i=0;i<n;i++)
		cout<<ans[i];

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
long a[26],b[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s;
	cin>>t;
	long n,i,j,k;
	n=s.size();
	char ans[n+1];

	for(i=0;i<n;i++)
		{
		 a[s[i]-'a']++;
		 b[t[i]-'a']++;
		}
	j=0;
	k=25;
	while(b[k]==0)
				k--;
	while(a[j]==0)
			j++;
	for(i=0;i<n;i++)
	{
		if(i%2==0){

		 while(a[j]==0)
			j++;
		 if(j<=k)
		 	ans[i] =char('a'+j);
		 else
		 	break;
		 a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			if(k>=j)
				ans[i] = char('a'+k);
			else
				break;
			b[k]--;
		}
	}
	long f=i;
	string x="",y="";
	char cc;
	for(i;i<n;i++)
	{
		if(i%2==0)
		{
			while(a[j]==0)
			j++;
		 	cc=char('a'+j);
		 	x = x+cc;
		 	a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			cc = char('a'+k);
			y = y+cc;
			b[k]--;
		}
	}
	j=0;
	k=0;
	//cout<<x<<endl;
	//cout<<y<<endl;
	for(i=n-1;i>=f;i--)
	{
		if((f%2)^((n-1-i)%2)==0)
			{ans[i]=x[j];
				j++;}
		else
		{
			ans[i]=y[k];
			k++;
		}
	}

	for(i=0;i<n;i++)
		cout<<ans[i];

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
long long a[26],b[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s;
	cin>>t;
	long long n,i,j,k;
	n=s.size();
	char ans[n+1];

	for(i=0;i<n;i++)
		{
		 a[s[i]-'a']++;
		 b[t[i]-'a']++;
		}
	j=0;
	k=25;
	while(b[k]==0)
				k--;
	while(a[j]==0)
			j++;
	for(i=0;i<n;i++)
	{
		if(i%2==0){

		 while(a[j]==0)
			j++;
		 if(j<=k)
		 	ans[i] =char('a'+j);
		 else
		 	break;
		 a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			if(k>=j)
				ans[i] = char('a'+k);
			else
				break;
			b[k]--;
		}
	}
	long long f=i;
	string x="",y="";
	char cc;
	for(i;i<n;i++)
	{
		if(i%2==0)
		{
			while(a[j]==0)
				j++;
		 	cc=char('a'+j);
		 	x = cc+x;
		 	a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			cc = char('a'+k);
			y = cc+y;
			b[k]--;
		}
	}
	j=0;
	k=0;
	//cout<<x<<endl;
	//cout<<y<<endl;
	for(i=n-1;i>=f;i--)
	{
		if((f&1)^((n-1-i)&1)==0)
			{ans[i]=x[j];
				j++;}
		else
		{
			ans[i]=y[k];
			k++;
		}
	}

	for(i=0;i<n;i++)
		cout<<ans[i];

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
long a[26],b[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s;
	cin>>t;
	long n,i,j,k;
	n=s.size();
	char ans[n+1];

	for(i=0;i<n;i++)
		{
		 a[s[i]-'a']++;
		 b[t[i]-'a']++;
		}
	j=0;
	k=25;
	for(i=0;i<n;i++)
	{
		if(i%2==0){

		 while(a[j]==0)
			j++;
		 if(j<=k)
		 	ans[i] =char('a'+j);
		 else
		 	break;
		 a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			if(k>=j)
				ans[i] = char('a'+k);
			else
				break;
			b[k]--;
		}
	}
	long x=i;
	for(i=n-1;i>=x;i--)
	{
		if(x%2==0 ){
		 if((n-1-i)%2==0)
		  {
			while(a[j]==0)
			j++;
			ans[i]=char('a'+j);
			a[j]--;
		  }
		 else
		  {
			while(b[k]==0)
				k--;
			ans[i]=char('a'+k);
			b[k]--;
		  }
		}
	else
		{
		  if((n-1-i)%2==1)
		  {
		  	while(a[j]==0)
			j++;
			ans[i]=char('a'+j);
			a[j]--;
		  }
		  else
		  {
		  	while(b[k]==0)
				k--;
			ans[i]=char('a'+k);
			b[k]--;
		  }
		}
	}
	for(i=0;i<n;i++)
		cout<<ans[i];

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
long a[26],b[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s;
	cin>>t;
	long n,i,j,k;
	n=s.size();
	char ans[n+1];

	for(i=0;i<n;i++)
		{
		 a[s[i]-'a']++;
		 b[t[i]-'a']++;
		}
	j=0;
	k=25;
	while(b[k]==0)
				k--;
	while(a[j]==0)
			j++;
	for(i=0;i<n;i++)
	{
		if(i%2==0){

		 while(a[j]==0)
			j++;
		 if(j<=k)
		 	ans[i] =char('a'+j);
		 else
		 	break;
		 a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			if(k>=j)
				ans[i] = char('a'+k);
			else
				break;
			b[k]--;
		}
	}
	long f=i;
	string x="",y="";
	char cc;
	for(i;i<n;i++)
	{
		if(i%2==0)
		{
			while(a[j]==0)
			j++;
		 	cc=char('a'+j);
		 	x = cc+x;
		 	a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			cc = char('a'+k);
			y = cc+y;
			b[k]--;
		}
	}
	j=0;
	k=0;
	//cout<<x<<endl;
	//cout<<y<<endl;
	for(i=n-1;i>=f;i--)
	{
		if((f%2)^((n-1-i)%2)==0)
			{ans[i]=x[j];
				j++;}
		else
		{
			ans[i]=y[k];
			k++;
		}
	}

	for(i=0;i<n;i++)
		cout<<ans[i];

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
long long a[26],b[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s;
	cin>>t;
	long long n,i,j,k;
	n=s.size();
	char ans[n+1];

	for(i=0;i<n;i++)
		{
		 a[s[i]-'a']++;
		 b[t[i]-'a']++;
		}
	j=0;
	k=25;
	while(b[k]==0 && k>=0)
				k--;
	while(a[j]==0 && j<=25)
			j++;
	for(i=0;i<n;i++)
	{
		if(i%2==0){
		 while(a[j]==0)
			j++;

		 if(j<k)
		 	ans[i] =char('a'+j);
		 else
		 	break;
		 a[j]--;
		  while(a[j]==0)
			j++;
		}
		else
		{
			while(b[k]==0)
				k--;
			if(k>j)
				ans[i] = char('a'+k);
			else
				break;
			b[k]--;
			while(b[k]==0)
				k--;
		}
	}
	long long f=i;
	char x[n+1],y[n+1];
	long aa=0,bb=0;
	char cc;
	for(i;i<n;i++)
	{
		if(i%2==0)
		{
			while(a[j]==0)
				j++;
		 	x[aa]=char('a'+j);
		 	aa++;
		 	a[j]--;
		 	while(a[j]==0)
				j++;
		}
		else
		{
			while(b[k]==0)
				k--;
			y[bb] = char('a'+k);
			bb++;
			b[k]--;
			while(b[k]==0)
				k--;
		}
	}
	j=aa-1;
	k=bb-1;
	//cout<<x<<endl;
	//cout<<y<<endl;
	for(i=n-1;i>=f;i--)
	{
		if((f&1)^((n-1-i)&1)==0)
			{ans[i]=x[j];
				j--;}
		else
		{
			ans[i]=y[k];
			k--;
		}
	}

	for(i=0;i<n;i++)
		cout<<ans[i];

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
long a[26],b[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>s;
	cin>>t;
	long n,i,j,k;
	n=s.size();
	char ans[n+1];

	for(i=0;i<n;i++)
		{
		 a[s[i]-'a']++;
		 b[t[i]-'a']++;
		}
	j=0;
	k=25;
	while(b[k]==0)
				k--;
	while(a[j]==0)
			j++;
	for(i=0;i<n;i++)
	{
		if(i%2==0){

		 while(a[j]==0)
			j++;
		 if(j<=k)
		 	ans[i] =char('a'+j);
		 else
		 	break;
		 a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			if(k>=j)
				ans[i] = char('a'+k);
			else
				break;
			b[k]--;
		}
	}
	long f=i;
	string x="",y="";
	char cc;
	for(i;i<n;i++)
	{
		if(i%2==0)
		{
			while(a[j]==0)
			j++;
		 	cc=char('a'+j);
		 	x = cc+x;
		 	a[j]--;
		}
		else
		{
			while(b[k]==0)
				k--;
			cc = char('a'+k);
			y = cc+y;
			b[k]--;
		}
	}
	j=0;
	k=0;
	for(i=f;i<n;i++)
	{
		if(i%2==0)
			{ans[i]=x[j];
				j++;}
		else
		{
			ans[i]=y[k];
			k++;
		}
	}

	for(i=0;i<n;i++)
		cout<<ans[i];

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

string s, t, ans;

int main(){
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  ans = s;
  int n = s.size();
  int oleg_best = 0, oleg_worst = n/2,
    igor_best = n-1, igor_worst = n - (n/2);

  if(n%2==0) oleg_worst--;

  int first = 0, last = n-1;
  for(int i = 0; i < n; i++){
    if(i % 2 == 0){
      // Oleg - lexicographically lowest
      if(s[oleg_best] < t[igor_best]){
        ans[first] = s[oleg_best];
        oleg_best++;
        first++;
      } else {
        // force igor to put his letter before my worst one
        // put my worst one at the end
        // this way the remaining empty string will be better or equal
        ans[last] = s[oleg_worst];

        oleg_worst--;
        last--;
      }

    } else{
      // Igor - lexicographically highest

      if(t[igor_best] > s[oleg_best]){
        ans[first] = t[igor_best];
        igor_best--;
        first++;
      } else {
        ans[last] = t[igor_worst];
        last--;
        igor_worst++;
      }
    }
  }

  cout << ans << "\n";
  return 0;
}


import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
import java.util.InputMismatchException;
import java.util.TreeMap;

public class c3po {

	static class Solver {

		int N, ans[][], AID = 0;
		TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, Integer>>> pts;

		// all points have same x and y; solve
		int solveY(TreeMap<Integer, Integer> ypts) {
			int last = -1;
			for(int z : ypts.keySet()) {
				z = ypts.get(z);
				if(last != -1) {
					ans[AID][0] = last;
					ans[AID++][1] = z;
					last = -1;
				} else
					last = z;
			}
			return last;
		}

		// all points have same x; solve
		int solveX(TreeMap<Integer, TreeMap<Integer, Integer>> xpts) {
			ArrayDeque<Integer> post = new ArrayDeque<>();
			for(int y : xpts.keySet()) {
				int go = solveY(xpts.get(y));
				if(go != -1) post.add(go);
			}
			while(!post.isEmpty()) {
				if(post.size() == 1) return post.pollFirst();
				ans[AID][0] = post.pollFirst();
				ans[AID++][1] = post.pollFirst();
			}
			return -1;
		}

		void add(int x, int y, int z, int id) {
			if (!pts.containsKey(x)) pts.put(x, new TreeMap<>());
			if (!pts.get(x).containsKey(y)) pts.get(x).put(y, new TreeMap<>());
			pts.get(x).get(y).put(z, id);
		}

		void solve(FastScanner s, PrintWriter out) {
			N = s.nextInt(); pts = new TreeMap<>();
			for(int x, y, z, i = 0; i < N; i++) {
				x = s.nextInt(); y = s.nextInt(); z = s.nextInt();
				add(x, y, z, i + 1);
			}

			ans = new int[N / 2][2];
			ArrayDeque<Integer> post = new ArrayDeque<>();
			for(int x : pts.keySet()) {
				int go = solveX(pts.get(x));
				if (go != -1) post.add(go);
			}
			while(!post.isEmpty()) {
				ans[AID][0] = post.pollFirst();
				ans[AID++][1] = post.pollFirst();
			}

			for(int[] a : ans)
				out.printf("%d %d%n", a[0], a[1]);
		}
	}

	public static void main(String[] args) {

		FastScanner s = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		Solver solver = new Solver();
		solver.solve(s, out);

		out.close();
		s.close();

	}

	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
		}

		public FastScanner(File f) throws FileNotFoundException {
			this(new FileInputStream(f));
		}

		public FastScanner(String s) {
			this.stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
		}

		void close() {
			try {
				stream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}

		// Jacob Garbage

		public int[] nextIntArray(int N) {
			int[] ret = new int[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextInt();
			return ret;
		}

		public int[][] next2DIntArray(int N, int M) {
			int[][] ret = new int[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextIntArray(M);
			return ret;
		}

		public long[] nextLongArray(int N) {
			long[] ret = new long[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextLong();
			return ret;
		}

		public long[][] next2DLongArray(int N, int M) {
			long[][] ret = new long[N][];
			for (int i = 0; i < N; i++)
				ret[i] = nextLongArray(M);
			return ret;
		}

		public double[] nextDoubleArray(int N) {
			double[] ret = new double[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDouble();
			return ret;
		}

		public double[][] next2DDoubleArray(int N, int M) {
			double[][] ret = new double[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDoubleArray(M);
			return ret;
		}

	}

}


import java.util.*;
import java.io.*;

public class BalancedRemovals
{

	public static void main(String[] args)
	{
		FS scan = new FS();
		int n = scan.nextInt();
		Pt[] arr = new Pt[n];
		int[] next = new int[n];
		for(int i = 0; i < n; i++){
			arr[i] = new Pt(scan.nextInt(), scan.nextInt(), scan.nextInt(), i+1);
			if(i > 0) next[i-1] = i;
		}
		Arrays.sort(arr);
//		for(int i = 0; i < n; i++){
//			System.out.print(arr[i].id+" ");
//		}
//		System.out.println();
		PrintWriter out = new PrintWriter(System.out);

		boolean[] used = new boolean[n];
//		System.out.println(Arrays.toString(next));
//		System.out.println(Arrays.toString(used));
		int i = 0;
		int last = -1;
		while(i < n){
			if(used[i]){
				i++;
				continue;
			}

			if(next[i] > i)
				if(arr[i].x == arr[next[i]].x && arr[i].y == arr[next[i]].y){
					used[i] = true;
					used[next[i]] = true;
					out.println(arr[i].id+" "+arr[next[i]].id);
					i++;
					continue;
				}
//			System.out.println("I: "+i);
//			System.out.println(last);
			if(last == -1) last = i;
			else{
				next[i] = -1;
				next[last] = i;
				last = -1;
			}

			i++;
		}

//		System.out.println(Arrays.toString(next));
//		System.out.println(Arrays.toString(used));

		i = 0;
		last = -1;
		while(i < n){
			if(used[i]){
				i++;
				continue;
			}

			if(next[i] > i)
				if(arr[i].x == arr[next[i]].x){
					used[i] = true;
					used[next[i]] = true;
					out.println(arr[i].id+" "+arr[next[i]].id);
					i++;
					continue;
				}

			if(last == -1) last = i;
			else{
				next[i] = -1;
				next[last] = i;
				last = -1;
			}

			i++;
		}
//		System.out.println("past 2nd sweep");
//		System.out.println(Arrays.toString(next));
//		System.out.println(Arrays.toString(used));

		for(i = 0; i < n; i++){
			if(!used[i]){
				out.println(arr[i].id+" "+arr[next[i]].id);
				used[i] = true;
				used[next[i]] = true;
			}
		}

		out.flush();
	}

	static class Pt implements Comparable<Pt>{

		int x;
		int y;
		int z;
		int id;

		public Pt(int x, int y, int z, int i){
			this.x = x;
			this.y = y;
			this.z = z;
			id = i;
		}

		@Override
		public int compareTo(Pt arg0)
		{
			if(this.x == arg0.x){
				if(this.y == arg0.y){
					return this.z-arg0.z;
				}
				return this.y-arg0.y;
			}
			return this.x-arg0.x;
		}
	}

	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;

public class BalancedRemovals
{

	public static void main(String[] args)
	{
		FS scan = new FS();
		int n = scan.nextInt();
		Pt[] arr = new Pt[n];
		int[] next = new int[n];
		for(int i = 0; i < n; i++){
			arr[i] = new Pt(scan.nextInt(), scan.nextInt(), scan.nextInt(), i+1);
			if(i > 0) next[i-1] = i;
		}
		Arrays.sort(arr);
		PrintWriter out = new PrintWriter(System.out);

		boolean[] used = new boolean[n];
		int i = 0;
		int last = -1;
		while(i < n){
			if(used[i]){
				i++;
				continue;
			}

			if(arr[i].x == arr[next[i]].x && arr[i].y == arr[next[i]].y){
				used[i] = true;
				used[next[i]] = true;
				out.println(arr[i].id+" "+arr[next[i]].id);
				i++;
				continue;
			}
			if(last == -1) last = i;
			else{
				next[last] = i;
				last = -1;
			}

			i++;
		}

		i = 0;
		last = -1;
		while(i < n){
			if(used[i]){
				i++;
				continue;
			}

			if(arr[i].x == arr[next[i]].x){
				used[i] = true;
				used[next[i]] = true;
				out.println(arr[i].id+" "+arr[next[i]].id);
				i++;
				continue;
			}
			if(last == -1) last = i;
			else{
				next[last] = i;
				last = -1;
			}
			i++;
		}

		for(i = 0; i < n; i++){
			if(!used[i]){
				out.println(arr[i].id+" "+arr[next[i]].id);
				used[i] = true;
				used[next[i]] = true;
			}
		}

		out.flush();
	}

	static class Pt implements Comparable<Pt>{

		int x;
		int y;
		int z;
		int id;

		public Pt(int x, int y, int z, int i){
			this.x = x;
			this.y = y;
			this.z = z;
			id = i;
		}

		@Override
		public int compareTo(Pt arg0)
		{
			if(this.x == arg0.x){
				if(this.y == arg0.y){
					return this.z-arg0.z;
				}
				return this.y-arg0.y;
			}
			return this.x-arg0.x;
		}
	}

	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;

public class BalancedRemovals
{

	public static void main(String[] args)
	{
		FS scan = new FS();
		int n = scan.nextInt();
		Pt[] arr = new Pt[n];
		int[] next = new int[n];
		Arrays.fill(next, -1);
		for(int i = 0; i < n; i++){
			arr[i] = new Pt(scan.nextInt(), scan.nextInt(), scan.nextInt(), i+1);
			if(i > 0) next[i-1] = i;
		}
		Arrays.sort(arr);
//		for(int i = 0; i < n; i++){
//			System.out.print(arr[i].id+" ");
//		}
//		System.out.println();
		PrintWriter out = new PrintWriter(System.out);

		boolean[] used = new boolean[n];
//		System.out.println(Arrays.toString(next));
//		System.out.println(Arrays.toString(used));
		int i = 0;
		int last = -1;
		while(i < n){
			if(used[i]){
				i++;
				continue;
			}

			if(next[i] != -1)
				if(arr[i].x == arr[next[i]].x && arr[i].y == arr[next[i]].y){
					used[i] = true;
					used[next[i]] = true;
					out.println(arr[i].id+" "+arr[next[i]].id);
					i++;
					continue;
				}
//			System.out.println("I: "+i);
//			System.out.println(last);
			if(last == -1) last = i;
			else{
				next[i] = -1;
				next[last] = i;
				last = -1;
			}

			i++;
		}

//		System.out.println(Arrays.toString(next));
//		System.out.println(Arrays.toString(used));

		i = 0;
		last = -1;
		while(i < n){
			if(used[i]){
				i++;
				continue;
			}

			if(next[i] != -1)
				if(arr[i].x == arr[next[i]].x){
					used[i] = true;
					used[next[i]] = true;
					out.println(arr[i].id+" "+arr[next[i]].id);
					i++;
					continue;
				}

			if(last == -1) last = i;
			else{
				next[i] = -1;
				next[last] = i;
				last = -1;
			}

			i++;
		}
//		System.out.println("past 2nd sweep");
//		System.out.println(Arrays.toString(next));
//		System.out.println(Arrays.toString(used));

		for(i = 0; i < n; i++){
			if(!used[i]){
				out.println(arr[i].id+" "+arr[next[i]].id);
				used[i] = true;
				used[next[i]] = true;
			}
		}

		out.flush();
	}

	static class Pt implements Comparable<Pt>{

		int x;
		int y;
		int z;
		int id;

		public Pt(int x, int y, int z, int i){
			this.x = x;
			this.y = y;
			this.z = z;
			id = i;
		}

		@Override
		public int compareTo(Pt arg0)
		{
			if(this.x == arg0.x){
				if(this.y == arg0.y){
					return this.z-arg0.z;
				}
				return this.y-arg0.y;
			}
			return this.x-arg0.x;
		}
	}

	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;

public class BalancedRemovals
{

	public static void main(String[] args)
	{
		FS scan = new FS();
		int n = scan.nextInt();
		Pt[] arr = new Pt[n];
		int[] next = new int[n];
		Arrays.fill(next, -1);
		for(int i = 0; i < n; i++){
			arr[i] = new Pt(scan.nextInt(), scan.nextInt(), scan.nextInt(), i+1);
			if(i > 0) next[i-1] = i;
		}
		Arrays.sort(arr);

		PrintWriter out = new PrintWriter(System.out);

		boolean[] used = new boolean[n];
//		System.out.println(Arrays.toString(next));
//		System.out.println(Arrays.toString(used));
		int i = 0;
		int last = -1;
		while(i < n){
			if(used[i]){
				i++;
				continue;
			}

			if(next[i] != -1)
				if(arr[i].x == arr[next[i]].x && arr[i].y == arr[next[i]].y){
					used[i] = true;
					used[next[i]] = true;
					out.println(arr[i].id+" "+arr[next[i]].id);
					i++;
					continue;
				}
//			System.out.println("I: "+i);
//			System.out.println(last);
			if(last == -1) last = i;
			else{
				next[i] = -1;
				next[last] = i;
				last = i;
			}

			i++;
		}

//		System.out.println(Arrays.toString(next));
//		System.out.println(Arrays.toString(used));

		i = 0;
		last = -1;
		while(i < n){
			if(used[i]){
				i++;
				continue;
			}

			if(next[i] != -1)
				if(arr[i].x == arr[next[i]].x){
					used[i] = true;
					used[next[i]] = true;
					out.println(arr[i].id+" "+arr[next[i]].id);
					i++;
					continue;
				}

			if(last == -1) last = i;
			else{
				next[i] = -1;
				next[last] = i;
				last = i;
			}

			i++;
		}
//		System.out.println("past 2nd sweep");
//		System.out.println(Arrays.toString(next));
//		System.out.println(Arrays.toString(used));

		for(i = 0; i < n; i++){
			if(!used[i]){
				out.println(arr[i].id+" "+arr[next[i]].id);
				used[i] = true;
				used[next[i]] = true;
			}
		}

		out.flush();
	}

	static class Pt implements Comparable<Pt>{

		int x;
		int y;
		int z;
		int id;

		public Pt(int x, int y, int z, int i){
			this.x = x;
			this.y = y;
			this.z = z;
			id = i;
		}

		@Override
		public int compareTo(Pt arg0)
		{
			if(this.x == arg0.x){
				if(this.y == arg0.y){
					return this.z-arg0.z;
				}
				return this.y-arg0.y;
			}
			return this.x-arg0.x;
		}
	}

	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}