n, a = int(input()), input().split()
ta = list((int(c[1]), i, c) for i, c in enumerate(a))
ca = sorted(ta)

ba = ta[:]
for i in range(n):
    for j in range(n - 1, i, -1):
        if ba[j][0] < ba[j - 1][0]:
            ba[j], ba[j - 1] = ba[j - 1], ba[j]

print(*[t[2] for t in ba])
print(('Not s' if ba != ca else 'S') + 'table')

sa = ta[:]
for i in range(n):
    minj = i
    for j in range(i, n):
        if sa[j][0] < sa[minj][0]:
            minj = j
    if minj != i:
        sa[i], sa[minj] = sa[minj], sa[i]

print(*[t[2] for t in sa])
print(('Not s' if sa != ca else 'S') + 'table') n, a = int(input()), input().split() n int(input()) int input() input a input().split() ().split () input split ta = list((int(c[1]), i, c) for i, c in enumerate(a)) ta list((int(c[1]), i, c) for i, c in enumerate(a)) list (int(c[1]), i, c) int(c[1]) int c[1] c 1 i c ca = sorted(ta) ca sorted(ta) sorted ta ba = ta[:] ba ta[:] ta : for i in range(n):
    for j in range(n - 1, i, -1):
        if ba[j][0] < ba[j - 1][0]:
            ba[j], ba[j - 1] = ba[j - 1], ba[j] i range(n) range n for j in range(n - 1, i, -1):
        if ba[j][0] < ba[j - 1][0]:
            ba[j], ba[j - 1] = ba[j - 1], ba[j] j range(n - 1, i, -1) range n - 1 n 1 i -1 if ba[j][0] < ba[j - 1][0]:
            ba[j], ba[j - 1] = ba[j - 1], ba[j] ba[j][0] < ba[j - 1][0] ba[j][0] [j] ba j 0 ba[j - 1][0] [j - 1] ba j - 1 j 1 0 ba[j], ba[j - 1] = ba[j - 1], ba[j] ba[j] ba j ba[j - 1] ba j - 1 j 1 ba[j - 1] ba j - 1 j 1 ba[j] ba j t[2] for t in ba for t in ba t ba for t in ba t[2] t 2 print(*[t[2] for t in ba]) print *[t[2] for t in ba] [t[2] for t in ba] print(('Not s' if ba != ca else 'S') + 'table') print ('Not s' if ba != ca else 'S') + 'table' 'Not s' if ba != ca else 'S' ba != ca ba ca 'Not s' 'S' 'table' sa = ta[:] sa ta[:] ta : for i in range(n):
    minj = i
    for j in range(i, n):
        if sa[j][0] < sa[minj][0]:
            minj = j
    if minj != i:
        sa[i], sa[minj] = sa[minj], sa[i] i range(n) range n minj = i minj i for j in range(i, n):
        if sa[j][0] < sa[minj][0]:
            minj = j
     j range(i, n) range i n if sa[j][0] < sa[minj][0]:
            minj = j
     sa[j][0] < sa[minj][0] sa[j][0] [j] sa j 0 sa[minj][0] [minj] sa minj 0 minj = j minj j if minj != i:
        sa[i], sa[minj] = sa[minj], sa[i] minj != i minj i sa[i], sa[minj] = sa[minj], sa[i] sa[i] sa i sa[minj] sa minj sa[minj] sa minj sa[i] sa i t[2] for t in sa for t in sa t sa for t in sa t[2] t 2 print(*[t[2] for t in sa]) print *[t[2] for t in sa] [t[2] for t in sa] print(('Not s' if sa != ca else 'S') + 'table') print ('Not s' if sa != ca else 'S') + 'table' 'Not s' if sa != ca else 'S' sa != ca sa ca 'Not s' 'S' 'table' sa = ta[:] ta[:] sa ba = ta[:] ta[:] ba a = int(input()), input().split() input().split() a ca = sorted(ta) sorted(ta) ca ta = list((int(c[1]), i, c) for i, c in enumerate(a)) list((int(c[1]), i, c) for i, c in enumerate(a)) ta minj = i i minj n, a = int(input()), input().split() int(input()) n minj = j j minj
n, a = int(input()), input().split()
ta = list((int(c[1]), i, c) for i, c in enumerate(a))
ca = sorted(ta)

ba = ta[:]
for i in range(n):
    for j in range(n - 1, i, -1):
        if ba[j][0] < ba[j - 1][0]:
            ba[j], ba[j - 1] = ba[j - 1], ba[j]

print(*[t[2] for t in ba])
print(('Not s' if ba != ca else 'S') + 'table')

sa = ta[:]
for i in range(n):
    minj = i
    for j in range(i, n):
        if sa[j][0] < sa[minj][0]:
            minj = j
    if minj != i:
        sa[i], sa[minj] = sa[minj], sa[i]

print(*[t[2] for t in sa])
print(('Not s' if sa != ca else 'S') + 'table')