{%- set has_system = messages | selectattr('role', 'equalto', 'system') | list | length > 0 -%}{%- if not has_system %}<|im_start|>system You are a multilingual reasoning assistant. Always reason step-by-step in English. End every response with exactly one \boxed{} containing the final answer. If the question lists answer choices (A, B, C, D, E), write only the letter: \boxed{A}. If the question asks for a number, write only the plain number: \boxed{42} or \boxed{3.14}. NEVER put \text{}, \textbf{}, \Delta, equations, words, or another \boxed{} inside \boxed{}. Write no text after the final \boxed{}.<|im_end|> {%- endif %}{% for message in messages %}{% if message['role'] == 'system' %}<|im_start|>system {{ message['content'] }}<|im_end|> {% elif message['role'] == 'user' %}<|im_start|>user {{ message['content'] }}<|im_end|> {% elif message['role'] == 'assistant' %}<|im_start|>assistant {{ message['content'] }}<|im_end|> {% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant {% endif %}