Thank you for your response. But I need only even digits in the first modality and odd digits in the second modality. Your code yields an output (n,n+1) but I would like (2n,2n+1). So, for example (0,1) is allowed but (1,2) is not allowed