ABad=zeros(n);
for i=1:n
    for j=1:n
        ABad(i,j)=j+(i-1)*n;
    end
end
ABad            