In a school of more than 500 students, when the students were standing in a row of 7, 5 students were left out. When these students were standing in a row of 10, again 5 students were left out and when they were standing in a row of 15, 5 students were left out again. If each time, at least one row was formed and the number of students in the school is the least possible, then find the average of the number of rows formed in the above three cases.