Mutation#966

Mutation

1 saniye
256 megabayt
Zor

Scientists on the planet Olympia are conducting an experiment to mutate a primitive test organism into a target primitive organism. The genomes of these organisms are represented as sequences of genes, where each gene is encoded by the digit or . The experiment proceeds in several stages. At each stage, some genes in the test organism's genome are flipped to their opposite values (i.e., from to and vice versa). The scientists can choose which genes to flip, but the number of genes flipped at each stage is fixed and may be different for each mutation stage. Both the test and target organisms have genomes of the same length. It is known that the genomes consist of repeated sequences called the base sequence.

Giriş

The first line contains four integers , , , and (1 \leq A \leq 40000, 1 \leq B \leq 40000, 1 \leq N \leq 2 \times 10^9, 1 \leq M \leq 100000). Here, and are the lengths of the base sequences for the test and target organisms, respectively. is the length of the genomes of both organisms; it is guaranteed that is divisible by both and . is the maximum number of mutation stages that scientists can perform. The second and third lines provide the base sequences for the test and target organisms, consisting only of and , with lengths and respectively. Each of the following lines contains a natural number not exceeding — the number of genes flipped in the -th stage. It is guaranteed that the mutation can be completed in or fewer stages.

Çıktı

Print a single integer — the minimum number of mutation stages required to obtain the target organism's genome from the test organism's genome.

Örnekler

Örnek 1

Loading
Loading