Under construction

Still being built. Things may change

Journey

Interview

Time limit2sMemory limit1024 MB

Summary
Given taken seats and the seats Lida wants (out of 54), find the fewest ticket ranges that buy every wanted seat without buying any unwanted free seat.
Level

Medium4 of 10

Topics
Greedy, Implementation
Solved
No attempts yet

Statement

Lida was bored in the northern city of Saint Petersburg. She decided to travel with her friends, so she went to the railway station and found a ticket system there. One request books all free seats in the range from kk to rr (1≤k≤r≤541 \le k \le r \le 54, inclusive), and it ignores seats that are already taken in that range. Lida is in a hurry, so she wants to make the smallest possible number of ticket requests. She knows which seat each of her friends wants, so she only buys tickets for those seats.

Given the list of taken seats and the seats Lida needs, find the minimum number of requests needed to buy them.

Input

The first line contains two integers nn (0≤n≤540 \le n \le 54), the number of seats already taken, and ll (0≤l≤540 \le l \le 54), the number of people traveling.

The second line contains nn distinct integers aia_i (1≤ai≤541 \le a_i \le 54), the taken seats.

The third line contains ll distinct integers bib_i (1≤bi≤541 \le b_i \le 54), the seats that Lida and her friends want.

Output

On the first line, print the number of requests pp. Then print pp lines, each with two numbers: the left and right bounds of one request.

If the tickets cannot be bought the way Lida and her friends want, print −1-1.

Examples1

  1. Example 1

    Input
    2 3
    2 5
    1 3 7
    
    Expected output
    2
    1 3
    7 7