%author: BB
\documentclass[11pt]{article} 
\input shared.texm 
\startfile
\psset{unit=1,labelsep=0.01}
\begin{pspicture}(-4.5,-1.3)(4.5,1.2)
\def\xa{2}\def\xb{4}
\def\NN#1#2{\cnode[fillstyle=solid,fillcolor=lightgray](#1,0){0.4}{q#2}\rput(#1,0){$p_{#2}$}}
\NN{-\xb}{0}
\NN{-\xa}{1}
\NN{0}{2}
\NN{\xa}{3}
\NN{\xb}{4}
\psset{arrows=->}
\ncline{q0}{q1}\aput{0.5}{$a$}
\ncline{q1}{q2}\aput{0.5}{$a$}
\ncline{q2}{q3}\aput{0.5}{$b$}
\ncline{q3}{q4}\aput{0.5}{$a$}
\pscircle(4,0){0.5}
\nccircle[arcangleA=60,arcangleB=120]{q0}{0.4}\bput{0.5}{$b$}
\nccircle[arcangleA=30,arcangleB=120]{q2}{0.4}\bput{0.5}{$a$}
\ncarc[arcangleA=-40,arcangleB=-40]{q1}{q0}\bput(0.2){$b$}
\ncarc[arcangleA=20,arcangleB=20]{q3}{q0}\aput(0.2){$b$}
\ncarc[arcangleA=30,arcangleB=30]{q4}{q0}\aput(0.2){$b$}
\ncarc[arcangleA=-30,arcangleB=-30]{q4}{q2}\bput(0.2){$a$}
\end{pspicture}\endfile
