A finishes the work in 16 days.
A finishes 1/16 of the work in one day.
A had worked for two days= 2*1/16 = 1/8
the work left after A has worked for two days = 1- 1/8 = 7/8
B finihses the work in 12 days
in 1 day B finishes 1/12 of the work.
A and B togeher in one day can finish= 1/16+1/12 = (3+4)/48= 7/48 of work
A and B together can complete the remaining work= (7/8) / (7/48)= 7*48/8*7 = 6 days.
therefore total time taken = 2 days by A alone + 6 days by both Aand B = 8 days