Formation of the Mg II h&k lines in various so