Markets gain