GOV-internship 3
Definition. Hamming distance between two strings of equal length is the number of positions in which these strings differ.
Definition. Distance from text s to pattern p is the sum of all Hamming distances between the pattern and all substrings of text which have length |p|.
You are given text s and pattern p. Either text or pattern, but not both, can be damaged (some symbols are lost). Your task is to reconstruct the damaged string so that the Hamming distance between the text and the pattern will be the least possible.
Input
The first line contains the length n (1 ≤ n ≤ 100000) of the text s. The second line contains the text represented as n integer numbers t_i (0 ≤ t_i ≤ 100000) separated by whitespaces. The third line contains one integer m: the length of the pattern p (1 ≤ m < n). The fourth line contains the pattern in the same format. Positive numbers denote the number of the symbol in the alphabet, while zero denotes a lost symbol. It is guaranteed that if there are lost symbols in text, there are none it pattern and vice versa.
Output
Output the text and the pattern separated with a line break. All lost symbols must be reconstructed. If there are several ways to reconstruct symbols optimally, output any one of them.