function [r] = twofour (x)
for i = 1:3
    for j = 1:3
        for k = 1:3
            for l = 1:3
                r(i,j,k,l) = x((i-1)*3+k,(j-1)*3+l);
            end
        end
    end
end