First pour the water in the bucket into the 8-litre bottle, then 4 litres remain in the former.
Step 2: pour the water in the 8-litre bottle into the 5-litre bottle, now there'll be 4 litres in the bucket, 3 in the 8-litre bottle and 5 in the remaining one.
Then add the water in the 5-litre bottle to the bucket - there'll be 9 litres in the latter and 3 in the 8-litre one.
Now pour the water in the 8-litre bottle into the 5-litre bottle and fill the 8-litre bottle with the 12-litre bottle - there'll be 1 litres in the bucket, 8-litre one will be full and 3 litres will be in the 5-litre one.
Finally fill the 5-litre bottle using the 8-litre one and pour all the water in the 5-litre bottle into the bucket.