Foreign investors buy net $38bn in Japan stocks, hitting 12-year high