This question appeared in the first round.

You are given a string of length N which consists of ‘W’,‘L’,‘D’ or ‘?’ and an integer K.

W denotes win L denotes loss D denotes draw and ? denotes that the outcome is uncertain.

A team wins a tournament if they win at least K more games than the second team.

If the team has already won K more games the outcome of rest matches does not matter as they are played friendly.

Find total number of ways such that you can replace ‘?’ and your team wins.

Output result modulo 10^9+7 as number can be very large.

one of the test cases I remembered

N=5

K=3

string - ? ? ? ? ?

output - 27

I have no clue how to approach this question, can anyone help?