For an open organ pipe, the fundamental frequency is the first harmonic, while for a closed organ pipe, the first overtone is the third harmonic. The frequencies are matched using the formula for harmonics in pipes, and the length of each pipe is calculated.