In a physical education period, students are arranged in rows to form a perfect square to practice a display for the sports day. From the total number of 8046 students, 125 students were not well and others formed a perfect square to participate in the display. Find the number of students in each row.