Repair#4290

Repair

1 second
64 megabytes
Medium

Stepan recently purchased a new apartment and decided to apply wallpaper before his parents visit. Initially, it seemed straightforward, but he encountered a challenge when he realized he needed to align the patterns on adjacent strips of wallpaper. Being a skilled programmer, Stepan framed the problem as follows: Each strip of wallpaper can be represented by a section—a rectangle with a height of and a width of . This rectangle can be repeated to the right and left to form the complete strip. For simplicity, imagine dividing this rectangle into equal cells, creating rows and columns. The wallpaper pattern is represented using the symbols "." and "*" (dot and asterisk), with one symbol per cell.

You are provided with the descriptions of two wallpaper strips. Your task is to assist Stepan by writing a program that calculates the minimum number of cells the second strip must be shifted to the right to align its pattern with the first strip. The wallpaper is designed such that alignment is always possible.

Input

The first line of the input contains two integers and (1 \leq N \leq 20, 1 \leq M \leq 100000). The following lines each contain characters, describing the first strip of wallpaper. The next lines each contain characters, describing the second strip of wallpaper. Each line in the wallpaper description consists solely of the symbols "." and "*".

Output

The output should be a single number—the minimum number of cells the second strip needs to be shifted to the right to match the pattern on the first strip.

Examples

Example 1

Loading
Loading