ENSAT Eid practice #1 ( copy )

#### Start

2019-08-13 10:55 UTC

## ENSAT Eid practice #1 ( copy )

#### End

2019-08-16 12:55 UTC
The end is near!
Contest is over.
Not yet started.
Contest is starting in -233 days 2:24:43

74:00:00

0:00:00

# Problem DMath Homework

Source: pixabay

Since entering $2^\text {nd}$ grade Theta has daily math homework sheets. The problems on her worksheet usually go like this:

There is a certain number of birds, dogs, and cats on a farm. Together they have $14$ legs. How many birds, dogs, and cats could there be? Write down as many answers as you can!

It is always the same problem, just written in different ways: sometimes with horses, cows, sheep, goats, chickens, beetles, or even spiders – but never with snakes or fishes!

Can you write a program to double-check Theta’s answers?

## Input

Input consists of a single line with $4$ integers: $b$, $d$, $c$, and $l$, with $b$, $d$, and $c$ representing the numbers of legs the first, second, and third type of animal has. You are given that $0 < b, c, d \le 100$ because some farm animals in these math problems may be centipedes. The total number of legs is given by $l$ ($0 \le l \le 250$).

## Output

Output all possible answers, each on a separate line, in lexicographical order so that they are sorted by the number of the first animal, ties broken by the second and third animal numbers’, respectively. Separate the number of the first, second, and third animal with spaces. If there are no possible solutions, output impossible on a single line!

Sample Input 1 Sample Output 1
2 4 4 14

1 0 3
1 1 2
1 2 1
1 3 0
3 0 2
3 1 1
3 2 0
5 0 1
5 1 0
7 0 0

Sample Input 2 Sample Output 2
100 80 60 240

0 0 4
0 3 0
1 1 1

Sample Input 3 Sample Output 3
2 4 6 9

impossible