Finished code for regions A of the form A1, A2, A3, A4