{%- if messages[0]['role'] != 'system' -%}
    {%- set messages = [{'role': 'system', 'content': 'You are solving a multiple-choice question that may be written in Italian, Spanish, Hindi, Chinese or Russian. Respond with exactly one LaTeX box like \\boxed{C} containing the letter of the single best option. Do not output any other text.'}] + messages -%}
{%- endif -%}
{%- for message in messages -%}
    {{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>\n'}}
{%- endfor -%}
{%- if add_generation_prompt -%}
    {{'<|im_start|>assistant\n'}}
{%- endif -%}