#include <bits/stdc++.h>
using namespace std;
#define ms(s,n) memset(s,n,sizeof(s))
#define all(a) a.begin(),a.end()
#define present(t, x) (t.find(x) != t.end())
#define sz(a) int((a).size())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9+7;
const int INF = (int) 1e9+1;
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n, m; cin >> n >> m;
int b[n], c[m];
for(int i = 0; i < n; i++) cin >> b[i];
for(int i = 0; i < m; i++) cin >> c[i];
int i = 0, j = 0;
while(i < n && j < m){
if(b[i] <= c[j]){
cout << "b"<< i + 1 << " ";
++i;
}
else{
cout << "c" << j + 1 << " ";
++j;
}
}
while(i < n){
cout << "b"<< i + 1 << " ";
++i;
}
while(j < m){
cout << "c" << j + 1 << " ";
++j;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIG1zKHMsbikgbWVtc2V0KHMsbixzaXplb2YocykpCiNkZWZpbmUgYWxsKGEpIGEuYmVnaW4oKSxhLmVuZCgpCiNkZWZpbmUgcHJlc2VudCh0LCB4KSAodC5maW5kKHgpICE9IHQuZW5kKCkpCiNkZWZpbmUgc3ooYSkgaW50KChhKS5zaXplKCkpCiNkZWZpbmUgRk9SKGksIGEsIGIpIGZvciAoaW50IGkgPSAoYSk7IGkgPCAoYik7ICsraSkKI2RlZmluZSBGT1JkKGksIGEsIGIpIGZvciAoaW50IGkgPSAoYSkg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