Between 1 and 31, m numbers have been inserted in such a way that the resulting sequence is an A.P. and the ratio of 7th and (m – 1)th numbers is 5:9. Find the value of m.