A loading bay uses a single stack. Crates with distinct labels are pushed on in a fixed push order (each crate pushed exactly once). Between pushes, the top crate may be popped off at any time. Given a proposed pop order (a permutation of the same labels), decide whether it is possible to interleave pushes and pops so that crates are removed in exactly that order.
Input format
Line 1: an integer n, the number of crates.
Line 2: n space-separated distinct integers, the push order.
Line 3: n space-separated integers, the proposed pop order (a permutation of the push labels).
Output format
Print YES if the pop order is achievable, otherwise NO.
Constraints
- 1 <= n <= 100000
- The labels are distinct, and the pop line is a permutation of the push line.