Conversion from sum of product to product of sum I do not understand how did he convert from this to this.

Source :http://cs229.stanford.edu/notes/cs229-notes1.pdf 
Page 18
 A: This comes from basic properties of logarithms:
$$
\log(ab) = \log(a)+\log(b)
$$
and
$$
\log(a^b) = b\log(a)
$$
A: It uses the below logarithmic properties:
$(1) ~~~~~\log(a \cdot b) = \log a + \log b$
$(2) ~~~~~\log a^b = b \cdot \log a$
At first, you have
$$ 
\log L(\theta) = \log \left( \prod_{i=1}^m \left(h_\theta(x^{(i)})\right)^{y^{(i)}}\left(1 - h_\theta(x^{(i)})\right)^{1-y^{(i)}}\right)
$$
By the first equation, the product in the argument of $\log$ becomes a sum of $\log$s.
$$
\log L(\theta) = \sum_{i=1}^m \left( \log \left( h_\theta(x^{(i)})\right)^{y^{(i)}}\left(1 - h_\theta(x^{(i)}) \right)^{1-y^{(i)}}\right)
$$
But, again because of the first equation, you have that 
$\log \left( h_\theta(x^{(i)})\right)^{y^{(i)}}\left(1 - h_\theta(x^{(i)}) \right) = \log\left( h_\theta(x^{(i)})\right)^{y^{(i)}} + \log \left( 1- h_\theta(x^{(i)})\right)^{1-y^{(i)}}$
And then, because of equation (2), you have
$\log\left( h_\theta(x^{(i)})\right)^{y^{(i)}} + \log \left( 1-h_\theta(x^{(i)})\right)^{1-y^{(i)}} = y^{(i)} \log (h_\theta(x^{(i)})) + (1-y^{(i)})\log\left( 1-h_\theta(x^{(i)})\right)$
In the end, you get
$$
\log L(\theta) = \sum_{i=1}^m \left( y^{(i)} \log (h_\theta(x^{(i)})) + (1-y^{(i)})\log\left( 1-h_\theta(x^{(i)})\right)\right)
$$
