About the Benefits of Nails
I returned to my room, exhausted from the disco and having indulged in plenty of yogurt. Not in the mood to chat about the lecturers with my roommates again, I began to survey the room. Over the past day, nothing had changed: the beds, nightstands, and the wardrobe without shelves remained in the same spots as yesterday.
On one of the walls, there were n nails hammered in, one below the other. To brighten up the atmosphere, I decided to hang some of the p photos from various LKS shifts on them. The photos were already framed, each with a loop at the top for hanging on the nails.
I want to hang as many photos as possible, ensuring they are in chronological order from bottom to top (the higher the photo is hung, the later it should have been taken). I don't want the photos to overlap, and I won't hang a photo on a nail if the photo's height exceeds the height at which the nail is hammered, as this would cause its lower part to hang below floor level.
I have already measured the heights at which the nails are hammered and the heights of the photos. Help me determine the maximum number of photos I can hang.
Input
The first line contains the integers n and p (1 ≤ n ≤ 10^4, 1 ≤ p ≤ 100). The second line contains n integers - the heights from the floor level where the nails are placed. The heights are listed in ascending order. The third line contains p integers - the heights of the photos. The photos are listed from the earliest to the latest. The heights of the nails and photos are positive and do not exceed 10^4.
Output
In the first line, output a single number k - the maximum number of photos I can hang in the room. In each of the next k lines, output two numbers separated by a space - the photo number and the nail number on which it will be hung. Photos can be output in any order. Nails are numbered from 1 to n in the order they are described in the input. Photos are numbered from 1 to p in the order they are described in the input.