Royal Croquet
"Everyone to their places!" shouted the Queen in a booming voice. Instantly, everyone dashed around, colliding, tumbling, and scrambling back up. But within a minute, they were all in position. Has the game begun?
Alice's Adventures in Wonderland (translated by N.M. Demurova)
Alice thought she had never seen such a peculiar croquet field: it was riddled with holes and furrows. Hedgehogs were used as balls, flamingos as mallets, and soldiers as hoops, forming a bridge and standing still while the game was in progress.
However, there was another peculiar rule, the breach of which could provoke the Queen's dreadful anger. In royal croquet, N teams participate (the i-th team has A_i players), and they must be distributed across M sectors (the j-th sector can hold B_j players). The game cannot commence until all players are allocated to the sectors such that no two players from the same team are in the same sector.
Can the game proceed?
Input
The first line contains 2 natural numbers N and M (1 ≤ N, M ≤ 100), indicating the number of teams and sectors, respectively. The second line lists N numbers, representing the number of players in each team. No team has more than 100 players. The third line lists M numbers, representing the capacity of each sector. Each sector can hold at least one and no more than one hundred players.
Output
On the first line, print 1 if Alice can play croquet, and 0 otherwise. If the answer is positive, also print N lines, where the i-th line contains the sector numbers for the players of team number i. If multiple solutions exist, any one of them is acceptable.