All the credit for this answer goes to Stefan V.
The big clues are the yellow flame colour ("Na"Na) and the brown gas ("NO"_2NO2 or, less likely, "Br"_2Br2).
"NO"_2NO2 comes from the decomposition of "HNO"_2HNO2.
This implies "NaNO"_2NaNO2 and, along with other evidence, "NaNO"_3NaNO3.
color(red)(bb"A" = "NaNO"_3)A=NaNO3
2underbrace("NaNO"_3)_color(red)("A") stackrelcolor(blue)(Δcolor(white)(X)) (→) 2underbrace("NaNO"_2)_color(red)("B") + underbrace("O"_2)_color(red)("C")
color(red)(bb"C" = "O"_2)
"O"_2 is a colourless gas that forms "MgO" when heated with "Mg".
"O"_2 + "2Mg" → "2MgO"
"MgO" is a basic oxide.
"MgO" + "H"_2"O" ⇌ "Mg"^(2+) + "2OH"^(-)
color(red)(bb"B" = "NaNO"_2)
"NaNO"_2 reacts with sulfuric acid to form "HNO"_2, which decomposes to form the brown gas "NO"_2.
2underbrace("NaNO"_2)_color(red)("B") + "H"_2"SO"_4 → "2HNO"_2 + "Na"_2"SO"_4
"2HNO"_2 → underbrace("NO"_2)_color(red)("brown") + "NO" + "H"_2"O"
color(red)(bb"D" = "N"_2) and color(red)(bb"E" = "NaCl")
"NaNO"_2 reacts with "NH"_4"Cl" to form "N"_2 and "NaCl".
underbrace("NaNO"_2)_color(red)("B") + "NH"_4"Cl" → underbrace("N"_2)_color(red)("D") + underbrace("NaCl")_color(red)("E") + "2H"_2"O"
"N"_2 reacts with "Ca" to form "Ca"_3"N"_2.
"3Ca" + "N"_2 stackrelcolor(blue)(Δcolor(white)(X))(→) "Ca"_3"N"_2
"Ca"_3"N"_2 reacts with water to form ammonia and "Ca"("OH")_2.
"Ca"_3"N"_2 + 6"H"_2"O" → 3underbrace("Ca"("OH")_2)_color(red)("basic") + 2underbrace("NH"_3)_color(red)("colourless")
color(red)(bb"F" = "N"_2"O") and color(red)(bb"G" = "Na"_2"SO"_4")
"NaNO"_3 reacts with ("NH"_4)_2"SO"_4 to form "N"_2"O" and "Na"_2"SO"_4
2underbrace("NaNO"_3)_color(red)("A") + ("NH"_4)_2"SO"_4 stackrelcolor(blue)(Δcolor(white)(X))(→) 2underbrace("N"_2"O")_color(red)("F") + underbrace("Na"_2"SO"_4)_color(red)("G") + "4H"_2"O"
The "Na" in "Na"_2"SO"_4 gives the yellow flame colour.