3This is the same code as the original file, but with extraneous prints removed for simplicity.