Returnin matrices from path betweeen A and B