q=3: first=1 last=4 count=4
q=9: first=6 last=7 count=2
q=5: first=-1 last=-1 count=0
