Because I can't do mental arithmetic, I often struggle with the Kakuro Puzzle, which requires the victim to repeatedly work out which distinct numbers in the range 1 to 9 (inclusive) sum to another number in range 1 to 45 when you know how many numbers there are. For example, if you may want to know how to get 23 from 3 numbers, the only answer is 6 + 8 + 9. (This is the same idea as Killer Sudoku if you are familiar with that).
Sometimes you will have other information, such as that the number 1 cannot be present, thus to achieve 8 in just 2 numbers, you can only use 2 + 6 and 3 + 5 (you can't use 4 + 4, because they are not distinct). Alternatively, it may be that you have already found a 3 in the solution, and so something like 19 in 3 numbers must be 3 + 7 + 9.
Your task is to write a program that lists all the possible solutions to a given problem, in a strict order, in a strict layout.
Your solution can receive the inputs as a single ASCII string either through stdin, a command line argument, an argument to a function, a value left on the stack, or whatever madness your favourite esoteric language employs. The string is in the form
number_to_achieve number_of_numbers_required list_of_rejected_numbers list_of_required_numbers
The first 2 arguments are typical base-10 non-negative non-zero integers in the ranges 1 to 45 and 1 to 9 respectively (using a decimal point would be invalid input), the two lists are just digits strung together with no delimitation in no particular order without repetition, or '0' if they are empty lists. There can be no shared digits between the lists (except for 0). The delimiters are single spaces.
Your output must start with a line that contains the number of possible solutions. Your program must print out line-break delimited solutions sorted by each increasingly significant digit, where each digit is placed at the position it would be if you listed the numbers from 1 to 9. The examples below will hopefully make this clearer.
If an invalid input is provided I do not care what your program does, though I'd rather it didn't zero my boot sector.
For this example input
19 3 0 0
The expected output would be
5 2 89 3 7 9 4 6 9 4 78 56 8
Note the spaces in place of each "missing" number, these are required; I'm not bothered about spaces which don't have a number after them (such as the missing 9s above). You can assume that whatever you are printing to will use a mono-space font. Note also the ordering, whereby solutions with a smaller smallest digit are listed first, and then those with a smallest next smallest digit, etc.
Another example, based on that above
19 3 57 9
The expected output would be
2 2 89 4 6 9
Note that every result contains a 9, and no result contains a 5 or 7.
If there are no solutions, for example
20 2 0 0
Then you should just output a single line with a 0 on it.
I've intentionally made the parsing of the input part of the fun of this question. This is code-golf, may the shortest solution win.