#include <bits/stdc++.h>
using i64 = long long;
#ifdef DEBUG
#include "debug.h"
#else
#define debug(...) void(23)
#endif
constexpr int inf = int(1E9) + 5;
template<typename T>
bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<typename T>
bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N;
std::cin >> N;
std::vector<int> A(N * 2), B(N * 2);
for (int i = 0; i < N * 2; ++i) {
std::cin >> A[i];
}
for (int i = 0; i < N * 2; ++i) {
std::cin >> B[i];
}
// std::vector<int> f(N * 2 + 1, inf);
// for (int i = 0; i < N * 2; ++i) {
// std::vector<int> nf(N * 2 + 1, inf);
// for (int j = 0; j <= N * 2; ++j) {
// if (f[j] == inf) {
// continue;
// }
// if (f[j] <= A[i]) {
// chmin(nf[j], A[i]);
// }
// if (f[j] <= B[i]) {
// chmin(nf[j + 1], B[i]);
// }
// }
// f = std::move(nf);
// debug(f);
// }
// [f]: {2, 6, 0, 0, 0, 0, 0}
// [f]: {5, 7, 7, 0, 0, 0, 0}
// [f]: {0, 6, 0, 0, 0, 0, 0}
// [f]: {0, 9, 8, 0, 0, 0, 0}
// [f]: {0, 15, 12, 12, 0, 0, 0}
// [f]: {0, 0, 0, 14, 14, 0, 0}
std::vector<std::array<int, 2>> mind(N * 2, {inf, inf});
std::vector<std::array<int, 2>> maxd(N * 2, {-inf, -inf});
mind[0][0] = maxd[0][0] = 0;
mind[0][1] = maxd[0][1] = 1;
for (int i = 1; i < N * 2; ++i) {
for (int j = 0; j < 2; ++j) {
for (int k = 0; k < 2; ++k) {
if ((k ? B : A)[i - 1] <= (j ? B : A)[i]) {
chmin(mind[i][j], mind[i - 1][k] + (j == 1));
chmax(maxd[i][j], maxd[i - 1][k] + (j == 1));
}
}
}
}
debug(mind);
debug(maxd);
auto work = [&](int y) -> void {
int x = N * 2 - 1, have = N;
std::string ans(N * 2, '?');
while (x > 0) {
ans[x] = 'A' + y;
have -= (y == 1);
int ny = -1;
for (int j = 0; j < 2; ++j) {
if ((j ? B : A)[x - 1] <= (y ? B : A)[x]) {
if (mind[x - 1][j] <= have && have <= maxd[x - 1][j]) {
ny = j;
}
}
}
x--;
assert(ny != -1);
y = ny;
}
ans[x] = 'A' + y;
std::cout << ans << '\n';
};
if (mind[N * 2 - 1][0] <= N && N <= maxd[N * 2 - 1][0]) {
work(0);
} else if (mind[N * 2 - 1][1] <= N && N <= maxd[N * 2 - 1][1]) {
work(1);
} else {
std::cout << "-1\n";
}
return 0;
}