Const
a:array[1..2] of string=('','A');
b:array[1..2] of string=('','B');
c:array[1..2] of string=('','C');
d:array[1..2] of string=('','D');
var
i,j,k,l:byte;
begin
for i:=1 to 2 do
for j:=1 to 2 do
for k:=1 to 2 do
for l:=1 to 2 do
Write(d[i],c[j],b[k],a[l],' ')
end.
Тестовое решение:
A B BA C CA CB CBA D DA DB DBA DC DCA DCB DCBA