Column is painted so , make vis [ col ] = true
vis [ col ] = True NEW_LINE res += ( ( helper ( col + 1 , 0 , painted + 1 , 1 , N , P , K ) ) % mod ) NEW_LINE res += ( ( helper ( col + 1 , 0 , painted + 1 , 2 , N , P , K ) ) % mod ) NEW_LINE res += ( ( helper ( col + 1 , 0 , painted + 1 , 3 , N , P , K ) ) % mod ) NEW_LINE