Know (something) backwards and forwards

To know something very well.

I know the names of the people in my history class backwards and forwards.