The distribution of mass in M 31