Of course if you want to take your question very precisely and only avoid breaking between q1 and q2 (and say allow a break between q2 and q2) then the problem gets a little more interesting:
\catcode`\@=11
\addtoparstylehooks{\xdef\lastmarker{\m@rker}}
\m@kedigitsletters
\def\@qone{q1}
\m@kedigitsother
\sethook{before}{q2}{\ifx\lastmarker\@qone\relax\nobreak\fi}
Here we grab the marker of the previous paragraph at the end of each paragraph, then before a q2 we test that the last paragraph marker was a q1 and if so insert the nobreak. Notice that to compare the marker against q1, we store q1 as something to compare, but the 1 in q1 is a letter not a digit so we have to recategorise digits as letters while we do that def and then put them back. sethook is clever in that it does the recategorising for us without having to do that kind of thing.