Team Building#10566

Team Building

1 seconde
128 mégaoctets
Difficile

Every year, Farmer John brings his cows to compete for the title of "best in show" at the state fair. His arch-rival, Farmer Paul, brings his cows to compete as well.

Each of the n + m cows at the event receives an individual integer score. However, the final competition this year will be decided based on teams of cows, as follows: Farmer John and Farmer Paul each select a team of of their respective cows to compete. The cows on the two teams are then paired off according to their scores: the highest-scoring cow on FJ's team is paired with the highest-scoring cow on FP's team, the second-highest-scoring cows are paired together, and so on. FJ wins if, in every pair, his cow has a higher score than the corresponding cow on FP's team.

Please help FJ count the number of different ways he and FP can choose their teams such that FJ wins the contest. In other words, count each distinct pair consisting of a set of cows chosen by FJ and a set of cows chosen by FP for which FJ wins. Print the answer modulo 10^9 + 9.

Entrée

The first line contains three integers , and k~(1 \le n, m \le 1000, 1 \le k \le 10). The value of is no larger than either or . The next line contains the scores of FJ's cows.

The final line contains the scores of FP's cows.

Sortie

Print the number of ways FJ and FP can choose their teams such that FJ wins, modulo 10^9 + 9.

Exemples

Exemple 1

Loading
Loading