Added configurable n and q values (2 and 6 default)