Fix referee.py

template[i][j] might be already filled, which should be the same as ch.