This is easy,
First you wanna line up all the sides of the perimeter:
Let's do number 29.
We have (5h+2p) + (3h+p) + (2h+4p) + (2h+4p).
Now, if your familiar with Like Terms you should get this pretty easily.
Let's add the first two,
(5h+2p)+(3h+p)=8h+3p
Next the other two,
(2h+4p)+(2h+4p)=2h+8p
Add them both,
8h+3p+2h+8p= 10h+11p
Answer: 10h+11p