import random
prompt_candidates = {
    "You are given a {n} x {m} grid representing a Campsite puzzle. In the grid:\n- 'T' represents a tree.\n- 'X' represents an empty space where a tent can be placed.\n- Row and column constraints indicating the exact number of tents ('C') to be placed in each row and column.\n1. Rules:\n  1. Each tent (C) must be orthogonally adjacent to exactly one tree (T).\n  2. Tents (C) cannot be adjacent to each other (including diagonally).\n  3. The number of tents in each row must match the row constraints.\n  4. The number of tents in each column must match the column constraints.\n  5. The number of tents must be equal to the number of trees.\n2. Input:\n{puzzle}":"en",
    "This is a {n} x {m} Campsite puzzle grid. In this puzzle:\n- 'T' marks the position of a tree.\n- 'X' indicates an empty space where you can place a tent.\n- Numbers at the end of each row and column show how many tents must be placed there.\n1. Rules:\n  1. Each tent (C) must be placed adjacent to exactly one tree (T) horizontally or vertically.\n  2. No tent can touch another tent, even diagonally.\n  3. Each row must contain exactly the number of tents shown in the row constraints.\n  4. Each column must contain exactly the number of tents shown in the column constraints.\n  5. The total number of tents must equal the total number of trees.\n2. Input:\n{puzzle}":"en",
    "You're presented with a {n} x {m} Campsite puzzle grid where:\n- 'T' symbols represent trees.\n- 'X' symbols represent empty spaces where tents can be placed.\n- Each row and column has a constraint indicating how many tents must be placed there.\n1. Rules:\n  1. Every tent (C) must be orthogonally adjacent to exactly one tree (T).\n  2. Tents cannot touch each other, even diagonally.\n  3. The number of tents in each row must equal the row constraint value.\n  4. The number of tents in each column must equal the column constraint value.\n  5. There must be exactly as many tents as there are trees.\n2. Input:\n{puzzle}": "en",    
    "Below is a {n} x {m} Campsite puzzle grid:\n- Trees are marked with 'T'.\n- Empty spaces where tents can be placed are marked with 'X'.\n- Numbers at the end of rows and columns indicate tent counts.\n1. Rules:\n  1. Each tent (C) must be placed next to exactly one tree (T) horizontally or vertically.\n  2. Tents cannot be adjacent to each other (including diagonally).\n  3. Each row must contain exactly the number of tents specified in the row constraints.\n  4. Each column must contain exactly the number of tents specified in the column constraints.\n  5. The total number of tents must match the total number of trees.\n2. Input:\n{puzzle}": "en",   
    "Here's a {n} x {m} Campsite logic puzzle:\n- 'T' symbols show the locations of trees.\n- 'X' symbols show empty spaces where tents can be placed.\n- Row and column constraints show the required number of tents in each row and column.\n1. Rules:\n  1. Each tent (C) must be horizontally or vertically adjacent to exactly one tree (T).\n  2. No tent can be adjacent to another tent (including diagonally).\n  3. The number of tents in each row must match the corresponding row constraint.\n  4. The number of tents in each column must match the corresponding column constraint.\n  5. The total number of tents must equal the total number of trees.\n2. Input:\n{puzzle}": "en",   
    "I'm presenting you with a {n} x {m} Campsite puzzle where:\n- Trees are represented by 'T'.\n- Empty spaces where tents can be placed are represented by 'X'.\n- Each row and column has a constraint showing how many tents must be placed there.\n1. Rules:\n  1. Each tent (C) must be placed orthogonally adjacent to exactly one tree (T).\n  2. Tents cannot touch each other, even diagonally.\n  3. Each row must contain exactly the number of tents indicated by its constraint.\n  4. Each column must contain exactly the number of tents indicated by its constraint.\n  5. The number of tents must equal the number of trees.\n2. Input:\n{puzzle}": "en",   
    "Consider this {n} x {m} Campsite puzzle grid:\n- 'T' represents the fixed position of a tree.\n- 'X' represents an empty space where a tent can be placed.\n- Numbers at the end of rows and columns indicate how many tents must be placed in each.\n1. Rules:\n  1. Each tent (C) must be horizontally or vertically adjacent to exactly one tree (T).\n  2. No tent can be adjacent to another tent (including diagonally).\n  3. Each row must contain exactly the number of tents specified by its constraint.\n  4. Each column must contain exactly the number of tents specified by its constraint.\n  5. The total number of tents must equal the total number of trees.\n2. Input:\n{puzzle}": "en",   
    "You have a {n} x {m} Campsite puzzle grid where:\n- Trees are marked as 'T'.\n- Empty spaces where tents can be placed are marked as 'X'.\n- Row and column constraints indicate the required number of tents in each row and column.\n1. Rules:\n  1. Each tent (C) must be placed orthogonally adjacent to exactly one tree (T).\n  2. Tents cannot be adjacent to each other (including diagonally).\n  3. The number of tents in each row must match the row constraint.\n  4. The number of tents in each column must match the column constraint.\n  5. There must be exactly as many tents as there are trees.\n2. Input:\n{puzzle}": "en",   
    "This {n} x {m} grid represents a Campsite puzzle where:\n- 'T' symbols indicate trees.\n- 'X' symbols indicate empty spaces where tents can be placed.\n- Numbers at the end of rows and columns show how many tents must be placed in each.\n1. Rules:\n  1. Each tent (C) must be horizontally or vertically adjacent to exactly one tree (T).\n  2. No tent can touch another tent, even diagonally.\n  3. Each row must contain exactly the number of tents specified by its constraint.\n  4. Each column must contain exactly the number of tents specified by its constraint.\n  5. The total number of tents must equal the total number of trees.\n2. Input:\n{puzzle}": "en",   
    "Examine this {n} x {m} Campsite puzzle grid:\n- Trees are represented by 'T'.\n- Empty spaces where tents can be placed are represented by 'X'.\n- Row and column constraints indicate how many tents must be placed in each row and column.\n1. Rules:\n  1. Each tent (C) must be orthogonally adjacent to exactly one tree (T).\n  2. Tents cannot be adjacent to each other (including diagonally).\n  3. The number of tents in each row must match the row constraint.\n  4. The number of tents in each column must match the column constraint.\n  5. The number of tents must equal the number of trees.\n2. Input:\n{puzzle}": "en",   
    "这是一个 {n} x {m} 的营地谜题。在网格中：\n- 'T' 代表树木。\n- 'X' 代表可以放置帐篷的空地。\n- 行和列约束表示每行每列必须放置的帐篷('C')数量。\n1. 规则：\n  1. 每个帐篷(C)必须与一棵树(T)正交相邻（上、下、左、右）。\n  2. 帐篷(C)之间不能相邻（包括对角线方向）。\n  3. 每行的帐篷数量必须符合行约束。\n  4. 每列的帐篷数量必须符合列约束。\n  5. 帐篷的总数必须等于树木的总数。\n2. 输入：\n{puzzle}": "zh",   
    "给你一个 {n} x {m} 的营地谜题网格，其中：\n- 'T' 表示树木的位置。\n- 'X' 表示可以放置帐篷的空地。\n- 行和列的末尾数字表示每行每列必须放置的帐篷数量。\n1. 规则：\n  1. 每个帐篷(C)必须与一棵树(T)水平或垂直相邻。\n  2. 帐篷之间不能相邻，即使是对角线方向也不行。\n  3. 每行的帐篷数量必须等于行约束值。\n  4. 每列的帐篷数量必须等于列约束值。\n  5. 帐篷的总数必须等于树木的总数。\n2. 输入：\n{puzzle}": "zh",   
    "这是一个 {n} x {m} 的营地逻辑谜题：\n- 'T' 符号代表树木。\n- 'X' 符号代表可以放置帐篷的空地。\n- 每行和每列都有一个约束，表示该行或列中必须放置的帐篷数量。\n1. 规则：\n  1. 每个帐篷(C)必须与一棵树(T)正交相邻。\n  2. 帐篷之间不能相邻（包括对角线方向）。\n  3. 每行的帐篷数量必须符合行约束。\n  4. 每列的帐篷数量必须符合列约束。\n  5. 帐篷的总数必须等于树木的总数。\n2. 输入：\n{puzzle}": "zh",   
    "下面是一个 {n} x {m} 的营地谜题网格：\n- 树木用'T'标记。\n- 可以放置帐篷的空地用'X'标记。\n- 行和列末尾的数字表示帐篷数量。\n1. 规则：\n  1. 每个帐篷(C)必须放在一棵树(T)的水平或垂直相邻位置。\n  2. 帐篷之间不能相邻（包括对角线方向）。\n  3. 每行必须包含行约束中指定的帐篷数量。\n  4. 每列必须包含列约束中指定的帐篷数量。\n  5. 帐篷的总数必须等于树木的总数。\n2. 输入：\n{puzzle}": "zh",   
    "这是一个 {n} x {m} 的营地放置谜题：\n- 'T' 符号表示树木的位置。\n- 'X' 符号表示可以放置帐篷的空地。\n- 行和列约束表示每行每列需要放置的帐篷数量。\n1. 规则：\n  1. 每个帐篷(C)必须与一棵树(T)水平或垂直相邻。\n  2. 帐篷不能互相接触，即使是对角线方向也不行。\n  3. 每行的帐篷数量必须符合对应的行约束。\n  4. 每列的帐篷数量必须符合对应的列约束。\n  5. 帐篷的总数必须等于树木的总数。\n2. 输入：\n{puzzle}": "zh",   
    "我给你一个 {n} x {m} 的营地谜题，其中：\n- 树木用'T'表示。\n- 可以放置帐篷的空地用'X'表示。\n- 每行和每列都有一个约束，表示必须放置的帐篷数量。\n1. 规则：\n  1. 每个帐篷(C)必须放在一棵树(T)的正交相邻位置。\n  2. 帐篷之间不能相互接触，即使是对角线方向也不行。\n  3. 每行必须包含其约束所指定的帐篷数量。\n  4. 每列必须包含其约束所指定的帐篷数量。\n  5. 帐篷的数量必须等于树木的数量。\n2. 输入：\n{puzzle}": "zh",   
    "考虑这个 {n} x {m} 的营地谜题网格：\n- 'T'表示树木的固定位置。\n- 'X'表示可以放置帐篷的空地。\n- 行和列末尾的数字表示每行每列必须放置的帐篷数量。\n1. 规则：\n  1. 每个帐篷(C)必须与一棵树(T)水平或垂直相邻。\n  2. 帐篷之间不能相邻（包括对角线方向）。\n  3. 每行必须包含其约束所指定的帐篷数量。\n  4. 每列必须包含其约束所指定的帐篷数量。\n  5. 帐篷的总数必须等于树木的总数。\n2. 输入：\n{puzzle}": "zh",   
    "你有一个 {n} x {m} 的营地谜题网格，其中：\n- 树木标记为'T'。\n- 可以放置帐篷的空地标记为'X'。\n- 行和列约束表示每行每列需要的帐篷数量。\n1. 规则：\n  1. 每个帐篷(C)必须放在一棵树(T)的正交相邻位置。\n  2. 帐篷之间不能相邻（包括对角线方向）。\n  3. 每行的帐篷数量必须符合行约束。\n  4. 每列的帐篷数量必须符合列约束。\n  5. 帐篷的数量必须等于树木的数量。\n2. 输入：\n{puzzle}": "zh",   
    "这个 {n} x {m} 的网格代表一个营地谜题，其中：\n- 'T'符号表示树木。\n- 'X'符号表示可以放置帐篷的空地。\n- 行和列末尾的数字表示每行每列必须放置的帐篷数量。\n1. 规则：\n  1. 每个帐篷(C)必须与一棵树(T)水平或垂直相邻。\n  2. 帐篷之间不能相互接触，即使是对角线方向也不行。\n  3. 每行必须包含其约束所指定的帐篷数量。\n  4. 每列必须包含其约束所指定的帐篷数量。\n  5. 帐篷的总数必须等于树木的总数。\n2. 输入：\n{puzzle}": "zh",   
    "请分析这个 {n} x {m} 的营地谜题网格：\n- 树木用'T'表示。\n- 可以放置帐篷的空地用'X'表示。\n- 行和列约束表示每行每列必须放置的帐篷数量。\n1. 规则：\n  1. 每个帐篷(C)必须与一棵树(T)正交相邻。\n  2. 帐篷之间不能相邻（包括对角线方向）。\n  3. 每行的帐篷数量必须符合行约束。\n  4. 每列的帐篷数量必须符合列约束。\n  5. 帐篷的数量必须等于树木的数量。\n2. 输入：\n{puzzle}": "zh"  
}


def prompt_campsite(grid, row_constraints, col_constraints):
    n = len(grid)
    m = len(grid[0]) if n > 0 else 0
    
    grid_str = ""
    for row in grid:
        grid_str += "  ".join(row) + "  \n"
    
    puzzle = f"{grid_str}\nrow_constraints = {row_constraints}\ncol_constraints = {col_constraints}"
    prompt = random.choice(list(prompt_candidates.keys()))
    language = prompt_candidates[prompt]
    prompt = prompt.format(n=n, m=m, puzzle=puzzle)
    
    if language == "en":
        prompt += "\n3. Task\n  - Place tents ('C') in the grid following all rules.\n  - Output the completed grid as a 2D list (list of lists) in Python format.\n4. Example Output Format:\n[\n    ['T', 'C', 'X', 'X'],\n    ['X', 'X', 'T', 'C'],\n    ['X', 'X', 'X', 'T'],\n    ['X', 'C', 'T', 'C']\n]"
    elif language == "zh":
        prompt += "\n3. 任务\n  - 在网格中按照所有规则放置帐篷('C')。\n  - 以Python格式的二维列表(列表的列表)输出完成的网格。\n4. 示例输出格式:\n[\n    ['T', 'C', 'X', 'X'],\n    ['X', 'X', 'T', 'C'],\n    ['X', 'X', 'X', 'T'],\n    ['X', 'C', 'T', 'C']\n]"
    
    return prompt