Molarity of #"Q"#:
Assume that you have #"1 dm"^3# of the stock solution.
#"Mass of solution" = 1 color(red)(cancel(color(black)("dm"^3 color(white)(l)"stock"))) × "1.12 kg stock"/(1 color(red)(cancel(color(black)("dm"^3 color(white)(l)"stock")))) = "1.12 kg stock" = "1120 g stock"#
#"Mass of Q" = 1120 color(red)(cancel(color(black)("g stock"))) × "31 g Q"/(100 color(red)(cancel(color(black)("g stock")))) = "347 g Q"#
#"Moles of Q" = 347 color(red)(cancel(color(black)("g Q"))) × "1 mol Q"/(38.0 color(red)(cancel(color(black)("g Q")))) = "9.14 mol Q"#
#"Molarity" = "9.14 mol"/("1 dm"^3) = "9.1 mol/dm"^3#
Volume of stock solution
#c_1V_1 = c_2V_2#
#V_1 = V_2 × c_2/c_1#
In this problem,
#V_1 = "?"; color(white)(mmml)c_1 = "9.1 mol/dm"^3#
#V_2 = "500 cm"^3; c_2 = 5 color(white)(m)"mol/dm"^3#
#V_1 = "500 cm"^3 × (5 color(red)(cancel(color(black)("mol/dm"^3))))/(9.1 color(red)(cancel(color(black)("mol/dm"^3)))) = "270 cm"^3#