Due to variations in the performance of the evaluation system, an additional 2 seconds of time limit is provided for this problem.
The mex (shorthand for minimum excluded value) of a sequence is the smallest non-negative integer that is not in the sequence. For example:
While the mex function has applications in combinatorial game theory, it is still a rather niche method for mapping a sequence to an integer. In the absence of a more organic problem, we have repurposed this concept to construct a task of a somewhat artificial nature. Sorry!
Write a program that, given two sequences of positive integers and , evaluates the following recurrence: for ,
输入格式
Your program is to read from standard input. The first line contains a single integer, (), representing the length of the sequences. The second line contains positive integers () representing the sequence . The third line contains positive integers (), representing the sequence .
输出格式
Your program is to write to standard output. Print exactly one line consisting of space-separated integers, denoting .