This is my tikz code :
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shapes.geometric,arrows,fit,calc,positioning,automata,}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,auto,node distance=5 cm, scale = 0.6, transform shape]
\node[initial,state] (A) {$q_0$};
\node[state] (B) [right of=A,node distance=3 cm] {$q_1$};
\node[state] (C) [right of=B,node distance = 6.5 cm] {$q_2$};
\node[state] (D) [below right of=B] {$q_3$};
\node[state] (E) [below right of=D] {$q_5$};
\node[state] (F) [below left of=D] {$q_4$};
\path[->] (A) edge [above] node [align=center] {} (B)
(B) edge [loop above] node [align=center] {} (B)
edge [bend right,below] node [align=center] {} (C)
edge [left] node [align=center] {} (D)
(C) edge [loop above] node [align=center] {} (C)
edge [bend right,right] node [above,align=center] {} (B)
edge [right] node [align=center] {} (D)
(D) edge [bend left,right] node [align=center] {} (E)
edge [bend right,left] node [pos=0.4,align=center] {} (F)
(E) edge [bend left] node [pos=0.2,align=center] {} (D)
(F) edge [bend right,above] node [pos=0.6,align=center] {} (D)
edge [bend left] node [pos=0.7,align=center] {} (A);
\end{tikzpicture}
\end{document}
And this is the output:

I want to draw container boxes (possibly with dashed border) around {q1,q2,q3} and {q3,q4,q5} states and label them. How to do that in tikz?
I want the following output:






