Condition to check if the number of cells to be painted is equal to or more than 2 , then we can paint first and third row
if ( painted + 2 <= K ) { res += ( helper ( col + 1 , 0 , painted + 2 , 4 , N , P , K ) ) % mod ; } vis [ col ] = false ;