import random

# 中文提示语模板
CHINESE_PROMPTS = [
    "这是一个{grid_size}x{grid_size}的不等式数独游戏。游戏规则：\n1. 在n x n的网格中填入数字，使每行和每列都包含1到n的所有数字且不重复。\n2. 网格中有大于\">\"或小于\"<\"的不等式符号，表示相邻格子之间的数值关系。例如，如果一个格子上方有\">\"符号，则该格子的数字必须大于上方格子的数字。\n3. 部分格子会预先填入数字作为提示。\n4. 题目以矩阵形式给出，下方附有不等式约束，格式为(第i行,第j列) > (第x行,第y列)。\n\n当前题目：\n{grid}\n\n不等式约束：\n{constraints}\n\n请从左到右、从上到下依次提供每个数字，数字之间用空格分隔，每行用逗号分隔，最终答案用双方括号包裹。\n\n例如，如果答案是：\nA B C\nD E F\nG H I\n\n请输出 [[A B C,D E F,G H I]]。\n\n解题技巧：\n1. 观察不等式约束，找出可能的数字范围。\n2. 利用预填数字和不等式关系，逐步推理其他位置。\n3. 注意每行和每列的数字不能重复。",
    "这是一个{grid_size}x{grid_size}的不等式数独谜题。规则说明：\n1. 在n x n的网格中填入数字，每行和每列必须包含1到n的所有数字且不能重复。\n2. 网格中的不等式符号（\">\"或\"<\"）表示相邻格子之间的数值大小关系。\n3. 部分格子会预先填入数字作为提示。\n4. 题目以矩阵形式给出，下方附有不等式约束，格式为(第i行,第j列) > (第x行,第y列)。\n\n当前题目：\n{grid}\n\n不等式约束：\n{constraints}\n\n请按照以下格式输出答案：从左到右、从上到下依次提供每个数字，数字之间用空格分隔，每行用逗号分隔，最终答案用双方括号包裹。\n\n例如，如果答案是：\nA B C\nD E F\nG H I\n\n请输出 [[A B C,D E F,G H I]]。\n\n解题技巧：\n1. 先分析不等式约束，确定某些格子的可能数字范围。\n2. 结合预填数字和不等式关系，逐步推理其他位置。\n3. 注意每行和每列的数字不能重复。",
    "这是一个{grid_size}x{grid_size}的不等式数独。游戏规则：\n1. 在n x n的网格中填入数字，每行和每列必须包含1到n的所有数字且不能重复。\n2. 网格中的不等式符号（\">\"或\"<\"）表示相邻格子之间的数值大小关系。\n3. 部分格子会预先填入数字作为提示。\n4. 题目以矩阵形式给出，下方附有不等式约束，格式为(第i行,第j列) > (第x行,第y列)。\n\n当前题目：\n{grid}\n\n不等式约束：\n{constraints}\n\n请按照以下格式输出答案：从左到右、从上到下依次提供每个数字，数字之间用空格分隔，每行用逗号分隔，最终答案用双方括号包裹。\n\n例如，如果答案是：\nA B C\nD E F\nG H I\n\n请输出 [[A B C,D E F,G H I]]。\n\n解题技巧：\n1. 分析不等式约束，找出可能的数字范围。\n2. 利用预填数字和不等式关系，逐步推理其他位置。\n3. 注意每行和每列的数字不能重复。",
    "这是一个{grid_size}x{grid_size}的不等式数独。规则说明：\n1. 在n x n的网格中填入数字，每行和每列必须包含1到n的所有数字且不能重复。\n2. 网格中的不等式符号（\">\"或\"<\"）表示相邻格子之间的数值大小关系。\n3. 部分格子会预先填入数字作为提示。\n4. 题目以矩阵形式给出，下方附有不等式约束，格式为(第i行,第j列) > (第x行,第y列)。\n\n当前题目：\n{grid}\n\n不等式约束：\n{constraints}\n\n请按照以下格式输出答案：从左到右、从上到下依次提供每个数字，数字之间用空格分隔，每行用逗号分隔，最终答案用双方括号包裹。\n\n例如，如果答案是：\nA B C\nD E F\nG H I\n\n请输出 [[A B C,D E F,G H I]]。\n\n解题技巧：\n1. 先分析不等式约束，确定某些格子的可能数字范围。\n2. 结合预填数字和不等式关系，逐步推理其他位置。\n3. 注意每行和每列的数字不能重复。",
    "这是一个{grid_size}x{grid_size}的不等式数独。游戏规则：\n1. 在n x n的网格中填入数字，每行和每列必须包含1到n的所有数字且不能重复。\n2. 网格中的不等式符号（\">\"或\"<\"）表示相邻格子之间的数值大小关系。\n3. 部分格子会预先填入数字作为提示。\n4. 题目以矩阵形式给出，下方附有不等式约束，格式为(第i行,第j列) > (第x行,第y列)。\n\n当前题目：\n{grid}\n\n不等式约束：\n{constraints}\n\n请按照以下格式输出答案：从左到右、从上到下依次提供每个数字，数字之间用空格分隔，每行用逗号分隔，最终答案用双方括号包裹。\n\n例如，如果答案是：\nA B C\nD E F\nG H I\n\n请输出 [[A B C,D E F,G H I]]。\n\n解题技巧：\n1. 分析不等式约束，找出可能的数字范围。\n2. 利用预填数字和不等式关系，逐步推理其他位置。\n3. 注意每行和每列的数字不能重复。",
    "这是一个{grid_size}x{grid_size}的不等式数独。规则说明：\n1. 在n x n的网格中填入数字，每行和每列必须包含1到n的所有数字且不能重复。\n2. 网格中的不等式符号（\">\"或\"<\"）表示相邻格子之间的数值大小关系。\n3. 部分格子会预先填入数字作为提示。\n4. 题目以矩阵形式给出，下方附有不等式约束，格式为(第i行,第j列) > (第x行,第y列)。\n\n当前题目：\n{grid}\n\n不等式约束：\n{constraints}\n\n请按照以下格式输出答案：从左到右、从上到下依次提供每个数字，数字之间用空格分隔，每行用逗号分隔，最终答案用双方括号包裹。\n\n例如，如果答案是：\nA B C\nD E F\nG H I\n\n请输出 [[A B C,D E F,G H I]]。\n\n解题技巧：\n1. 先分析不等式约束，确定某些格子的可能数字范围。\n2. 结合预填数字和不等式关系，逐步推理其他位置。\n3. 注意每行和每列的数字不能重复。",
    "这是一个{grid_size}x{grid_size}的不等式数独。游戏规则：\n1. 在n x n的网格中填入数字，每行和每列必须包含1到n的所有数字且不能重复。\n2. 网格中的不等式符号（\">\"或\"<\"）表示相邻格子之间的数值大小关系。\n3. 部分格子会预先填入数字作为提示。\n4. 题目以矩阵形式给出，下方附有不等式约束，格式为(第i行,第j列) > (第x行,第y列)。\n\n当前题目：\n{grid}\n\n不等式约束：\n{constraints}\n\n请按照以下格式输出答案：从左到右、从上到下依次提供每个数字，数字之间用空格分隔，每行用逗号分隔，最终答案用双方括号包裹。\n\n例如，如果答案是：\nA B C\nD E F\nG H I\n\n请输出 [[A B C,D E F,G H I]]。\n\n解题技巧：\n1. 分析不等式约束，找出可能的数字范围。\n2. 利用预填数字和不等式关系，逐步推理其他位置。\n3. 注意每行和每列的数字不能重复。",
    "这是一个{grid_size}x{grid_size}的不等式数独。规则说明：\n1. 在n x n的网格中填入数字，每行和每列必须包含1到n的所有数字且不能重复。\n2. 网格中的不等式符号（\">\"或\"<\"）表示相邻格子之间的数值大小关系。\n3. 部分格子会预先填入数字作为提示。\n4. 题目以矩阵形式给出，下方附有不等式约束，格式为(第i行,第j列) > (第x行,第y列)。\n\n当前题目：\n{grid}\n\n不等式约束：\n{constraints}\n\n请按照以下格式输出答案：从左到右、从上到下依次提供每个数字，数字之间用空格分隔，每行用逗号分隔，最终答案用双方括号包裹。\n\n例如，如果答案是：\nA B C\nD E F\nG H I\n\n请输出 [[A B C,D E F,G H I]]。\n\n解题技巧：\n1. 先分析不等式约束，确定某些格子的可能数字范围。\n2. 结合预填数字和不等式关系，逐步推理其他位置。\n3. 注意每行和每列的数字不能重复。",
    "这是一个{grid_size}x{grid_size}的不等式数独。游戏规则：\n1. 在n x n的网格中填入数字，每行和每列必须包含1到n的所有数字且不能重复。\n2. 网格中的不等式符号（\">\"或\"<\"）表示相邻格子之间的数值大小关系。\n3. 部分格子会预先填入数字作为提示。\n4. 题目以矩阵形式给出，下方附有不等式约束，格式为(第i行,第j列) > (第x行,第y列)。\n\n当前题目：\n{grid}\n\n不等式约束：\n{constraints}\n\n请按照以下格式输出答案：从左到右、从上到下依次提供每个数字，数字之间用空格分隔，每行用逗号分隔，最终答案用双方括号包裹。\n\n例如，如果答案是：\nA B C\nD E F\nG H I\n\n请输出 [[A B C,D E F,G H I]]。\n\n解题技巧：\n1. 分析不等式约束，找出可能的数字范围。\n2. 利用预填数字和不等式关系，逐步推理其他位置。\n3. 注意每行和每列的数字不能重复。"
]

# 英文提示语模板
ENGLISH_PROMPTS = [
    "This is a {grid_size}x{grid_size} Futoshiki puzzle. Game rules:\n1. Fill in the n x n grid with numbers so that each row and column contains all numbers from 1 to n without repetition.\n2. There are inequality signs (greater than \">\" or less than \"<\") between certain squares in the grid. These inequality signs indicate the numerical relationship between two neighboring grids. For example, if a grid has a \">\" sign above it, then the number of that grid must be greater than the number of the grid above it.\n3. Some grids will give pre-filled numbers as hints.\n4. The questions are given as matrices and are accompanied by inequality constraints below in the form (row i, column j) > (row x, column y).\n\nCurrent puzzle:\n{grid}\n\nInequality constraints:\n{constraints}\n\nPlease provide each element in order from left to right, and from top to bottom, with each element separated by a space and each row separated by a comma. Ensure that your final answer is wrapped in double square brackets.\n\nFor example, if the answer is:\nA B C\nD E F\nG H I\n\nplease output [[A B C,D E F,G H I]].\n\nSolving tips:\n1. Analyze the inequality constraints to find possible number ranges.\n2. Use pre-filled numbers and inequality relationships to gradually deduce other positions.\n3. Remember that numbers cannot repeat in each row and column.",
    "This is a {grid_size}x{grid_size} Futoshiki puzzle. Rules:\n1. Fill in the n x n grid with numbers so that each row and column contains all numbers from 1 to n without repetition.\n2. There are inequality signs (greater than \">\" or less than \"<\") between certain squares in the grid. These inequality signs indicate the numerical relationship between two neighboring grids. For example, if a grid has a \">\" sign above it, then the number of that grid must be greater than the number of the grid above it.\n3. Some grids will give pre-filled numbers as hints.\n4. The questions are given as matrices and are accompanied by inequality constraints below in the form (row i, column j) > (row x, column y).\n\nCurrent puzzle:\n{grid}\n\nInequality constraints:\n{constraints}\n\nPlease provide each element in order from left to right, and from top to bottom, with each element separated by a space and each row separated by a comma. Ensure that your final answer is wrapped in double square brackets.\n\nFor example, if the answer is:\nA B C\nD E F\nG H I\n\nplease output [[A B C,D E F,G H I]].\n\nSolving tips:\n1. First analyze the inequality constraints to determine possible number ranges for certain cells.\n2. Combine pre-filled numbers and inequality relationships to gradually deduce other positions.\n3. Remember that numbers cannot repeat in each row and column.",
    "This is a {grid_size}x{grid_size} Futoshiki puzzle. Game rules:\n1. Fill in the n x n grid with numbers so that each row and column contains all numbers from 1 to n without repetition.\n2. There are inequality signs (greater than \">\" or less than \"<\") between certain squares in the grid. These inequality signs indicate the numerical relationship between two neighboring grids. For example, if a grid has a \">\" sign above it, then the number of that grid must be greater than the number of the grid above it.\n3. Some grids will give pre-filled numbers as hints.\n4. The questions are given as matrices and are accompanied by inequality constraints below in the form (row i, column j) > (row x, column y).\n\nCurrent puzzle:\n{grid}\n\nInequality constraints:\n{constraints}\n\nPlease provide each element in order from left to right, and from top to bottom, with each element separated by a space and each row separated by a comma. Ensure that your final answer is wrapped in double square brackets.\n\nFor example, if the answer is:\nA B C\nD E F\nG H I\n\nplease output [[A B C,D E F,G H I]].\n\nSolving tips:\n1. Analyze the inequality constraints to find possible number ranges.\n2. Use pre-filled numbers and inequality relationships to gradually deduce other positions.\n3. Remember that numbers cannot repeat in each row and column.",
    "This is a {grid_size}x{grid_size} Futoshiki puzzle. Rules:\n1. Fill in the n x n grid with numbers so that each row and column contains all numbers from 1 to n without repetition.\n2. There are inequality signs (greater than \">\" or less than \"<\") between certain squares in the grid. These inequality signs indicate the numerical relationship between two neighboring grids. For example, if a grid has a \">\" sign above it, then the number of that grid must be greater than the number of the grid above it.\n3. Some grids will give pre-filled numbers as hints.\n4. The questions are given as matrices and are accompanied by inequality constraints below in the form (row i, column j) > (row x, column y).\n\nCurrent puzzle:\n{grid}\n\nInequality constraints:\n{constraints}\n\nPlease provide each element in order from left to right, and from top to bottom, with each element separated by a space and each row separated by a comma. Ensure that your final answer is wrapped in double square brackets.\n\nFor example, if the answer is:\nA B C\nD E F\nG H I\n\nplease output [[A B C,D E F,G H I]].\n\nSolving tips:\n1. First analyze the inequality constraints to determine possible number ranges for certain cells.\n2. Combine pre-filled numbers and inequality relationships to gradually deduce other positions.\n3. Remember that numbers cannot repeat in each row and column.",
    "This is a {grid_size}x{grid_size} Futoshiki puzzle. Game rules:\n1. Fill in the n x n grid with numbers so that each row and column contains all numbers from 1 to n without repetition.\n2. There are inequality signs (greater than \">\" or less than \"<\") between certain squares in the grid. These inequality signs indicate the numerical relationship between two neighboring grids. For example, if a grid has a \">\" sign above it, then the number of that grid must be greater than the number of the grid above it.\n3. Some grids will give pre-filled numbers as hints.\n4. The questions are given as matrices and are accompanied by inequality constraints below in the form (row i, column j) > (row x, column y).\n\nCurrent puzzle:\n{grid}\n\nInequality constraints:\n{constraints}\n\nPlease provide each element in order from left to right, and from top to bottom, with each element separated by a space and each row separated by a comma. Ensure that your final answer is wrapped in double square brackets.\n\nFor example, if the answer is:\nA B C\nD E F\nG H I\n\nplease output [[A B C,D E F,G H I]].\n\nSolving tips:\n1. Analyze the inequality constraints to find possible number ranges.\n2. Use pre-filled numbers and inequality relationships to gradually deduce other positions.\n3. Remember that numbers cannot repeat in each row and column.",
    "This is a {grid_size}x{grid_size} Futoshiki puzzle. Rules:\n1. Fill in the n x n grid with numbers so that each row and column contains all numbers from 1 to n without repetition.\n2. There are inequality signs (greater than \">\" or less than \"<\") between certain squares in the grid. These inequality signs indicate the numerical relationship between two neighboring grids. For example, if a grid has a \">\" sign above it, then the number of that grid must be greater than the number of the grid above it.\n3. Some grids will give pre-filled numbers as hints.\n4. The questions are given as matrices and are accompanied by inequality constraints below in the form (row i, column j) > (row x, column y).\n\nCurrent puzzle:\n{grid}\n\nInequality constraints:\n{constraints}\n\nPlease provide each element in order from left to right, and from top to bottom, with each element separated by a space and each row separated by a comma. Ensure that your final answer is wrapped in double square brackets.\n\nFor example, if the answer is:\nA B C\nD E F\nG H I\n\nplease output [[A B C,D E F,G H I]].\n\nSolving tips:\n1. First analyze the inequality constraints to determine possible number ranges for certain cells.\n2. Combine pre-filled numbers and inequality relationships to gradually deduce other positions.\n3. Remember that numbers cannot repeat in each row and column.",
    "This is a {grid_size}x{grid_size} Futoshiki puzzle. Game rules:\n1. Fill in the n x n grid with numbers so that each row and column contains all numbers from 1 to n without repetition.\n2. There are inequality signs (greater than \">\" or less than \"<\") between certain squares in the grid. These inequality signs indicate the numerical relationship between two neighboring grids. For example, if a grid has a \">\" sign above it, then the number of that grid must be greater than the number of the grid above it.\n3. Some grids will give pre-filled numbers as hints.\n4. The questions are given as matrices and are accompanied by inequality constraints below in the form (row i, column j) > (row x, column y).\n\nCurrent puzzle:\n{grid}\n\nInequality constraints:\n{constraints}\n\nPlease provide each element in order from left to right, and from top to bottom, with each element separated by a space and each row separated by a comma. Ensure that your final answer is wrapped in double square brackets.\n\nFor example, if the answer is:\nA B C\nD E F\nG H I\n\nplease output [[A B C,D E F,G H I]].\n\nSolving tips:\n1. Analyze the inequality constraints to find possible number ranges.\n2. Use pre-filled numbers and inequality relationships to gradually deduce other positions.\n3. Remember that numbers cannot repeat in each row and column.",
    "This is a {grid_size}x{grid_size} Futoshiki puzzle. Rules:\n1. Fill in the n x n grid with numbers so that each row and column contains all numbers from 1 to n without repetition.\n2. There are inequality signs (greater than \">\" or less than \"<\") between certain squares in the grid. These inequality signs indicate the numerical relationship between two neighboring grids. For example, if a grid has a \">\" sign above it, then the number of that grid must be greater than the number of the grid above it.\n3. Some grids will give pre-filled numbers as hints.\n4. The questions are given as matrices and are accompanied by inequality constraints below in the form (row i, column j) > (row x, column y).\n\nCurrent puzzle:\n{grid}\n\nInequality constraints:\n{constraints}\n\nPlease provide each element in order from left to right, and from top to bottom, with each element separated by a space and each row separated by a comma. Ensure that your final answer is wrapped in double square brackets.\n\nFor example, if the answer is:\nA B C\nD E F\nG H I\n\nplease output [[A B C,D E F,G H I]].\n\nSolving tips:\n1. First analyze the inequality constraints to determine possible number ranges for certain cells.\n2. Combine pre-filled numbers and inequality relationships to gradually deduce other positions.\n3. Remember that numbers cannot repeat in each row and column.",
    "This is a {grid_size}x{grid_size} Futoshiki puzzle. Game rules:\n1. Fill in the n x n grid with numbers so that each row and column contains all numbers from 1 to n without repetition.\n2. There are inequality signs (greater than \">\" or less than \"<\") between certain squares in the grid. These inequality signs indicate the numerical relationship between two neighboring grids. For example, if a grid has a \">\" sign above it, then the number of that grid must be greater than the number of the grid above it.\n3. Some grids will give pre-filled numbers as hints.\n4. The questions are given as matrices and are accompanied by inequality constraints below in the form (row i, column j) > (row x, column y).\n\nCurrent puzzle:\n{grid}\n\nInequality constraints:\n{constraints}\n\nPlease provide each element in order from left to right, and from top to bottom, with each element separated by a space and each row separated by a comma. Ensure that your final answer is wrapped in double square brackets.\n\nFor example, if the answer is:\nA B C\nD E F\nG H I\n\nplease output [[A B C,D E F,G H I]].\n\nSolving tips:\n1. Analyze the inequality constraints to find possible number ranges.\n2. Use pre-filled numbers and inequality relationships to gradually deduce other positions.\n3. Remember that numbers cannot repeat in each row and column.",
    "This is a {grid_size}x{grid_size} Futoshiki puzzle. Rules:\n1. Fill in the n x n grid with numbers so that each row and column contains all numbers from 1 to n without repetition.\n2. There are inequality signs (greater than \">\" or less than \"<\") between certain squares in the grid. These inequality signs indicate the numerical relationship between two neighboring grids. For example, if a grid has a \">\" sign above it, then the number of that grid must be greater than the number of the grid above it.\n3. Some grids will give pre-filled numbers as hints.\n4. The questions are given as matrices and are accompanied by inequality constraints below in the form (row i, column j) > (row x, column y).\n\nCurrent puzzle:\n{grid}\n\nInequality constraints:\n{constraints}\n\nPlease provide each element in order from left to right, and from top to bottom, with each element separated by a space and each row separated by a comma. Ensure that your final answer is wrapped in double square brackets.\n\nFor example, if the answer is:\nA B C\nD E F\nG H I\n\nplease output [[A B C,D E F,G H I]].\n\nSolving tips:\n1. First analyze the inequality constraints to determine possible number ranges for certain cells.\n2. Combine pre-filled numbers and inequality relationships to gradually deduce other positions.\n3. Remember that numbers cannot repeat in each row and column."
]

def get_prompt(grid: str, constraints: str, grid_size: int, is_chinese: bool = False) -> str:
    """Get a random prompt template based on language preference."""
    prompts = CHINESE_PROMPTS if is_chinese else ENGLISH_PROMPTS
    template = random.choice(prompts)
    return template.format(
        grid=grid,
        constraints=constraints,
        grid_size=grid_size
    ) 