the period T of a simple pendulum is the amount of time required fot it to undergo one complete oscillation. if the lenght of the pendulum is L and the acceleration of gravity is g, then T is given by, T = 2Pi L^p g^q
T is in seconds or units of time.
L is in length
g is in length*time^(-2)
So L^p g^q has units (length)^p (length)^q *(time)^(-2q)
= (length)^(p+q) * (time)^(-2q)
This has to be equal to (time).
That tells you p+q = 0 since there's no length units on the left hand side
And -2q has to be equal to 1. So that tells you q, which tells you what p has to be.