Under construction

Still being built. Things may change

Final Standings

Time limit2sMemory limit512 MB

Summary
Given each team's strength, each problem's difficulty, and a frozen scoreboard, compute the probability that team t ends up in first place, assuming ties always go to team t.
Level

Medium7 of 10

Topics
Probability, Dynamic programming, Math
Solved
No attempts yet

Problem

The GCPC 2019 is finally over. You have worked for five hours and have solved as many problems as possible. However, you still do not know which place you have got, since the scoreboard is still frozen. Of course you think that you and your team have won GCPC 2019.

As there is always a lengthy pause between the end of the contest and unfreezing the scoreboards (someone has to print the certificates and someone has to re-compile the solution slides), you want to use your time to determine how probable it is that your team has won GCPC 2019.

You know the final scoreboard, that is, for all teams which problems they have solved prior to the freeze and which problems they have attempted during the freeze. Also you know from last year how good each team is and you trust your own estimates of each problem's difficulty. To be precise, if a team with strength s∈[0,1]s \in [0, 1] has attempted to solve a problem with difficulty d∈[0,1]d \in [0, 1], you assume that the probability of solving the problem is s⋅ds \cdot d.

As your team was very quick in solving the simple problems this year, you assume that a team can only have a higher place than you if they have solved more problems (you assume that you will always win the tie-break).

Input

  • The first line of input contains two integers tt and pp (1≤t,p≤1001 \le t, p \le 100), the number of teams and the number of problems in the contest. The teams are numbered 11 to tt and the problems are numbered 11 to pp. Your team is team tt.
  • The second line contains t−1t - 1 real numbers s1,…,st−1s_1, \ldots, s_{t-1} (0≤si≤10 \le s_i \le 1 for each ii), where sis_i is the strength of team ii.
  • The third line contains pp real numbers d1,…,dpd_1, \ldots, d_p (0≤dj≤10 \le d_j \le 1 for each jj), where djd_j is the difficulty of problem jj.
  • Then follow t−1t - 1 lines describing the state of the problems for the other teams. Every such line contains pp characters c1,…,cpc_1, \ldots, c_p, where cjc_j in the iith line describes the state of problem jj for team ii and is X if the team has solved the problem before the freeze, ? if the team submitted a program for this problem after the freeze, and - otherwise.
  • The last line of input describes the problems your team solved with pp characters, each being either X or -.

All real numbers in the input have at most six decimals.

Output

Output a single real number, the probability that your team won GCPC 2019. Your answer should have an absolute or relative error of at most 10−610^{-6}.

Examples2

  1. Example 1

    Input
    3 3
    0.95 0.95
    0.95 0.95 0.95
    ? ? ?
    X X -
    X X -
    
    Expected output
    0.264908
    
  2. Example 2

    Input
    2 5
    0.5
    0.1 0.2 0.3 0.4 0.5
    ? ? ? ? ?
    X - - - -
    
    Expected output
    0.8387625