Trace the Code

Trace the JavaScript code from the top down on scratch paper.
The objective is to deduce what the document.write() statements in the loops write to the page and what variables contain after the script is done executing.
See if your answers on scratch paper match what a Web browser shows when you load this page.