You can this code to achieve the above results. This is for Q2. Same way you can just reuse the code for Q3 and Q4 by just replacing c1 to c2 and c3 respectively.
Begin Unverified Perl
for(my $i=1;$i<11;$i++)
{
if (VALUE("Q1_r".$i."_c1")==1)
{
ADD("Q1RowList",$i);
}
}
End Unverified