function [X] = Tri_Ex6(n)

% Define a matrix with columns all the RHS
for i=1:n
    for j = 1:n
        B(i,j) = i+j-1;
        if B(i,j) > n
            B(i,j) = B(i,j) - n;
        end    
    end
end
fprintf('The RHS are the columns of \n')
B
for i=1:n
    d(i) = 5;
end
for i=1:n-1
    c(i) = -1;
    a(i) = -1;
end
% Save the diagonals 
dorig=d;aorig=a;corig=c;
% Initialize the solution matrix with zeros
% At the end, the columns of X will be the solution for each RHS, i.e.
% columns of B
X=zeros(n);

for s=1:n
   [x]=Tri(aorig,dorig,corig,B(:,s));
    X(:,s)=x;
end   

fprintf('The solutions corresponding each RHSs are the columns of\n')