Clear[p,q]
TransitionMatrix={{1 ,0,0,0,0},
{0,1,0,0,0},
{p,0,0,q,0},
{0,0,p,0,q},
{0,q,0,p,0}};
MatrixForm[TransitionMatrix]

Clear[proc]
proc=With[{p=1/2,q=1/2},
DiscreteMarkovProcess[5,({{1 ,0,0,0,0},
{0,1,0,0,0},
{p,0,0,q,0},
{0,0,p,0,q},
{0,q,0,p,0}})]];
Graph[proc,VertexSize->{"Scaled",0.07},VertexLabels->Thread[Range[5]->Map[Placed[Style[#,{Bold}],Center]&,states={"0","4","1","2","3"}]],ImageSize->Large,ImagePadding->25]

Rrr={{p,0},{0,0},{0,q}};
queue={{0,q,0},{p,0,q},{0,p,0}};
Nnn=Inverse[IdentityMatrix[3]-queue];
Bee=Nnn.Rrr;

q=1-p;
MatrixForm[Nnn]
MatrixForm[Bee]

p=1/2;
MatrixForm[MatrixPower[TransitionMatrix,3]]
MatrixForm[MatrixPower[TransitionMatrix,4]]
MatrixForm[MatrixPower[TransitionMatrix,5]]
MatrixForm[MatrixPower[TransitionMatrix,6]]
MatrixForm[MatrixPower[TransitionMatrix,7]]
MatrixForm[Nnn]
MatrixForm[Bee]

p=1/3;
N[MatrixForm[MatrixPower[TransitionMatrix,30]]]
Rrr={{p,0},{0,0},{0,q}};
queue={{0,q,0},{p,0,q},{0,p,0}};
Nnn=Inverse[IdentityMatrix[3]-queue];
Bee=Nnn.Rrr;
MatrixForm[Nnn]
Bee=Nnn.Rrr;
MatrixForm[Bee]