Biorthogonality of ${ \left\{ \cos { (nx) } \right\} }_{ n\in { N }_{ 0 } }$

I have to make such $ { g }_{ n }(f)$ (where is $ f\in { L }^{ P) }(0;\pi )$ ) that
$ $ { g }_{ n }(\cos { mx } )={ \delta }_{ nm }$ $

In another words , $ { \left\{ cos(nx) \right\} }_{ n\in { N }_{ 0 } }$ and $ { \left\{ { g }_{ n } \right\} }_{ n\in { N }_{ 0 } }$ are biorthogonal systems.

I took as the $ { g }_{ n }\left( f \right) \ \ $ function $ { g }_{ n }\left( f \right) =\frac { 2 }{ \pi } \int _{ 0 }^{ \pi }{ f\left( x \right) \cos { \left( nx \right) dx } } $ and checked $ $ { m\neq n,\quad g }_{ n }\left( \cos { \left( mx \right) } \right) =\frac { 2 }{ \pi } \int _{ 0 }^{ \pi }{ \cos { \left( mx \right) } \cos { \left( nx \right) dx=0 } } \ m=n\neq 0,{ \quad g }_{ n }\left( \cos { \left( mx \right) } \right) =\frac { 2 }{ \pi } \int _{ 0 }^{ \pi }{ \cos ^{ 2 }{ \left( nx \right) dx } } =1\ m=n=0,{ \quad g }_{ n }\left( \cos { \left( mx \right) } \right) =\frac { 2 }{ \pi } \int _{ 0 }^{ \pi }{ dx } =2$ $ yet it didn’t work,I would like to know is it possible creat such condition ,and how,or it is impossible