function Msk = mask4(N)
Msk = zeros(N,N,N,N);

for k4=1:N
    
    Msk(1:k4-1,1:k4-1,1:k4-1,k4) = 4*reshape(mask3(k4-1),k4-1,k4-1,k4-1,1);
    
    Msk(1:k4-1,1:k4-1,k4,k4) = 6*reshape(mask2(k4-1),k4-1,k4-1,1,1);
    
    Msk(1:k4-1,k4,k4,k4) = 4;
    
    Msk(k4,k4,k4,k4) = 1;
end;   


