Note: You should alter the form so that r > =3 . Otherwise you will get errors for r= 1 or 2.