If the mean of the following frequency distribution is 54, find the value of p. Hence, find the median for the distribution.
Class 0-20 20-40 40-60 60-80 80-100
Frequency 7 P 10 9 13