Hong Kong, Shanghai shares end higher