Let's say my generating functional for the connected moments is given by \begin{align} W[J]&=\underbrace { -\frac { 1 }{ 2N } \ln { ( } Na) }_{ { ring } } +\underbrace { \frac { 1 }{ N^{ 2 } } \left( -\frac { \lambda }{ 4! } \right) a^{ -2 }3 }_{ { double \ tadpole } } +\frac { 1 }{ N^{ 3 } } \frac { 1 }{ 2! } \left( -\frac { \lambda }{ 4! } \right) ^{ 2 }a^{ -4 }[\underbrace { 4! }_{ { melon } } +\underbrace { 2\left( \begin{array}{l} 4 \\ 2 \end{array} \right) \left( \begin{array}{l} 4 \\ 2 \end{array} \right) }_{ { bubble \ 2 }{ \ tadpoles } } ]\\ &+\frac { J^{ 2 } }{ 2! } \{ \underbrace { a^{ -1 } }_{ { edge } } +\underbrace { \frac { 1 }{ N } \left( -\frac { \lambda }{ 4! } \right) a^{ -3 }\left( \begin{array}{c} 4 \\ 2 \end{array} \right) 2 }_{ { tadpole } } +\frac { 1 }{ N^{ 2 } } \frac { 1 }{ 2! } \left( -\frac { \lambda }{ 4! } \right) ^{ 2 }a^{ -5 }[\underbrace { 2\left( \begin{array}{l} 4 \\ 2 \end{array} \right) 2\left( \begin{array}{l} 4 \\ 2 \end{array} \right) 2 }_{ { tadpole \ in \ tadpole } } +\underbrace { \left( \begin{array}{l} 4 \\ 2 \end{array} \right) \left( \begin{array}{l} 4 \\ 2 \end{array} \right) 2\cdot 2\cdot 2 }_{ tadpole 1PR \ tadpole } +\underbrace { 4\cdot 4\cdot 2\cdot 3! }_{ { open \ melon } } ] \end{align} where $a$ is the inverse propagator and $N$ is $\frac{1}{\hbar}$.
How do I explicitly calculate the Legendre-transformation to get the effective action?