Legia Warszawa and Real Madrid played out a six-goal thriller as the spoils were shared in their UEFA Champions League Group F encounter.