id
stringclasses
1 value
instruction
stringlengths
29
13k
trajectory
listlengths
2
406
length
int64
2
406
public_tests
listlengths
1
7
generated_tests
listlengths
0
100
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\n\n\nQ.sort()\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\n\n\nQ.sort()\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\nGB[X-1] = gs\n\n\nQ.sort()\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\nGB[X-1] = gs\nfor i, (a, b, c) in enumerate(ABC[X:X+Z], X):\n gs += - heappushpop(Q, a - c) + a\n \n\nQ.sort()\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\nGB[X-1] = gs\nfor i, (a, b, c) in enumerate(ABC[X:X+Z], X):\n gs += - heappushpop(Q, a - c) + a\n GB[i] = gs\n\n\nQ.sort()\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\nGB[X-1] = gs\nfor i, (a, b, c) in enumerate(ABC[X:X+Z], X):\n gs += - heappushpop(Q, a - c) + a\n GB[i] = gs\n\nSB = [None]*N\n\nQ.sort()\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\nGB[X-1] = gs\nfor i, (a, b, c) in enumerate(ABC[X:X+Z], X):\n gs += - heappushpop(Q, a - c) + a\n GB[i] = gs\n\nSB = [None]*N\nQ = [b - c for _, b, c in ABC[X+Z:]]\nQ.sort()\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\nGB[X-1] = gs\nfor i, (a, b, c) in enumerate(ABC[X:X+Z], X):\n gs += - heappushpop(Q, a - c) + a\n GB[i] = gs\n\nSB = [None]*N\nQ = [b - c for _, b, c in ABC[X+Z:]]\nQ.sort()\nss = sum(b for _, b, _ in ABC[X+Z:])\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\nGB[X-1] = gs\nfor i, (a, b, c) in enumerate(ABC[X:X+Z], X):\n gs += - heappushpop(Q, a - c) + a\n GB[i] = gs\n\nSB = [None]*N\nQ = [b - c for _, b, c in ABC[X+Z:]]\nQ.sort()\nss = sum(b for _, b, _ in ABC[X+Z:])\nSB[-Y-1] = ss\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\nGB[X-1] = gs\nfor i, (a, b, c) in enumerate(ABC[X:X+Z], X):\n gs += - heappushpop(Q, a - c) + a\n GB[i] = gs\n\nSB = [None]*N\nQ = [b - c for _, b, c in ABC[X+Z:]]\nQ.sort()\nss = sum(b for _, b, _ in ABC[X+Z:])\nSB[-Y-1] = ss\nfor i, (a, b, c) in enumerate(ABC[X+Z-1:X-1:-1], 1):\n i = -Y - i\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\nGB[X-1] = gs\nfor i, (a, b, c) in enumerate(ABC[X:X+Z], X):\n gs += - heappushpop(Q, a - c) + a\n GB[i] = gs\n\nSB = [None]*N\nQ = [b - c for _, b, c in ABC[X+Z:]]\nQ.sort()\nss = sum(b for _, b, _ in ABC[X+Z:])\nSB[-Y-1] = ss\nfor i, (a, b, c) in enumerate(ABC[X+Z-1:X-1:-1], 1):\n i = -Y - i\n ss += - heappushpop(Q, b - c) + b\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\nGB[X-1] = gs\nfor i, (a, b, c) in enumerate(ABC[X:X+Z], X):\n gs += - heappushpop(Q, a - c) + a\n GB[i] = gs\n\nSB = [None]*N\nQ = [b - c for _, b, c in ABC[X+Z:]]\nQ.sort()\nss = sum(b for _, b, _ in ABC[X+Z:])\nSB[-Y-1] = ss\nfor i, (a, b, c) in enumerate(ABC[X+Z-1:X-1:-1], 1):\n i = -Y - i\n ss += - heappushpop(Q, b - c) + b\n SB[i-1] = ss\n", "from heapq import heappushpop\nimport sys\nX, Y, Z = map(int, sys.stdin.readline().split())\nN = X+Y+Z\nABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nABC.sort(key = lambda x: x[0] - x[1], reverse = True)\n\nGB = [None]*N\nQ = [a - c for a, _, c in ABC[:X]]\nQ.sort()\ngs = sum(a for a, _, _ in ABC[:X])\nGB[X-1] = gs\nfor i, (a, b, c) in enumerate(ABC[X:X+Z], X):\n gs += - heappushpop(Q, a - c) + a\n GB[i] = gs\n\nSB = [None]*N\nQ = [b - c for _, b, c in ABC[X+Z:]]\nQ.sort()\nss = sum(b for _, b, _ in ABC[X+Z:])\nSB[-Y-1] = ss\nfor i, (a, b, c) in enumerate(ABC[X+Z-1:X-1:-1], 1):\n i = -Y - i\n ss += - heappushpop(Q, b - c) + b\n SB[i-1] = ss\nprint(max(i + j for i, j in zip(GB[X-1:X+Z], SB[X-1:X+Z])))\n" ]
14
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "from heapq import*;X,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\n", "from heapq import*;X,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\n", "from heapq import*;X,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\n", "from heapq import*;X,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];\n", "from heapq import*;X,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[~i][0]-A[~i][2])\n", "from heapq import*;X,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[~i][0]-A[~i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n", "from heapq import*;X,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[~i][0]-A[~i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n if i>=X:R[i+1]-=heappop(q2)\n", "from heapq import*;X,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[~i][0]-A[~i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n if i>=X:R[i+1]-=heappop(q2)\nprint(max(L[i]+R[~i]for i in range(Y,N-X+1)))\n" ]
9
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "uq = []\ncy = 0\n\n\nlq = []\ncx = 0\n", "import sys\n\n\nuq = []\ncy = 0\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\n\n\nuq = []\ncy = 0\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\n\n\nuq = []\ncy = 0\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n \n cy += y\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n \n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor _ in [0] * X:\n \n \n cx += x\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor _ in [0] * X:\n x, y, z = xyz.pop()\n \n cx += x\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor _ in [0] * X:\n x, y, z = xyz.pop()\n heappush(lq, x - z)\n cx += x\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor _ in [0] * X:\n x, y, z = xyz.pop()\n heappush(lq, x - z)\n cx += x\nLx = [cx]\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor _ in [0] * X:\n x, y, z = xyz.pop()\n heappush(lq, x - z)\n cx += x\nLx = [cx]\nfor _ in [0] * Z:\n x, y, z = xyz.pop()\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor _ in [0] * X:\n x, y, z = xyz.pop()\n heappush(lq, x - z)\n cx += x\nLx = [cx]\nfor _ in [0] * Z:\n x, y, z = xyz.pop()\n cx += x - heappushpop(lq, x - z)\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor _ in [0] * X:\n x, y, z = xyz.pop()\n heappush(lq, x - z)\n cx += x\nLx = [cx]\nfor _ in [0] * Z:\n x, y, z = xyz.pop()\n cx += x - heappushpop(lq, x - z)\n Lx += [cx]\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor _ in [0] * X:\n x, y, z = xyz.pop()\n heappush(lq, x - z)\n cx += x\nLx = [cx]\nfor _ in [0] * Z:\n x, y, z = xyz.pop()\n cx += x - heappushpop(lq, x - z)\n Lx += [cx]\n\nprint(max(map(sum, zip(Lx, Ly[::-1]))))\n" ]
19
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[~i][0]-A[~i][2])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[~i][0]-A[~i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[~i][0]-A[~i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n if i>=X:R[i+1]-=heappop(q2)\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[~i][0]-A[~i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n if i>=X:R[i+1]-=heappop(q2)\nprint(max(L[i]+R[~i]for i in range(Y,N-X+1)))\n" ]
9
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "cy=0\nhq=[]\n\nLy=[cy]\n\ncx=0\nhq=[]\n\nLx=[cx]\n", "import sys\n\n\ncy=0\nhq=[]\n\nLy=[cy]\n\ncx=0\nhq=[]\n\nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\n\n\ncy=0\nhq=[]\n\nLy=[cy]\n\ncx=0\nhq=[]\n\nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\n\n\ncy=0\nhq=[]\n\nLy=[cy]\n\ncx=0\nhq=[]\n\nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\n\n\ncy=0\nhq=[]\n\nLy=[cy]\n\ncx=0\nhq=[]\n\nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\nABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]\n\ncy=0\nhq=[]\n\nLy=[cy]\n\ncx=0\nhq=[]\n\nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\nABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]\nABC.sort(key=lambda x: x[0]-x[1])\ncy=0\nhq=[]\n\nLy=[cy]\n\ncx=0\nhq=[]\n\nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\nABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]\nABC.sort(key=lambda x: x[0]-x[1])\ncy=0\nhq=[]\nfor a,b,c in ABC[:y]:\n cy+=b\n \nLy=[cy]\n\ncx=0\nhq=[]\n\nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\nABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]\nABC.sort(key=lambda x: x[0]-x[1])\ncy=0\nhq=[]\nfor a,b,c in ABC[:y]:\n cy+=b\n heappush(hq,b-c)\nLy=[cy]\n\ncx=0\nhq=[]\n\nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\nABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]\nABC.sort(key=lambda x: x[0]-x[1])\ncy=0\nhq=[]\nfor a,b,c in ABC[:y]:\n cy+=b\n heappush(hq,b-c)\nLy=[cy]\nfor a,b,c in ABC[y:y+z]:\n cy+=b-heappushpop(hq,b-c)\n \ncx=0\nhq=[]\n\nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\nABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]\nABC.sort(key=lambda x: x[0]-x[1])\ncy=0\nhq=[]\nfor a,b,c in ABC[:y]:\n cy+=b\n heappush(hq,b-c)\nLy=[cy]\nfor a,b,c in ABC[y:y+z]:\n cy+=b-heappushpop(hq,b-c)\n Ly.append(cy)\ncx=0\nhq=[]\n\nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\nABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]\nABC.sort(key=lambda x: x[0]-x[1])\ncy=0\nhq=[]\nfor a,b,c in ABC[:y]:\n cy+=b\n heappush(hq,b-c)\nLy=[cy]\nfor a,b,c in ABC[y:y+z]:\n cy+=b-heappushpop(hq,b-c)\n Ly.append(cy)\ncx=0\nhq=[]\nfor a,b,c in ABC[y+z:]:\n cx+=a\n \nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\nABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]\nABC.sort(key=lambda x: x[0]-x[1])\ncy=0\nhq=[]\nfor a,b,c in ABC[:y]:\n cy+=b\n heappush(hq,b-c)\nLy=[cy]\nfor a,b,c in ABC[y:y+z]:\n cy+=b-heappushpop(hq,b-c)\n Ly.append(cy)\ncx=0\nhq=[]\nfor a,b,c in ABC[y+z:]:\n cx+=a\n heappush(hq,a-c)\nLx=[cx]\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\nABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]\nABC.sort(key=lambda x: x[0]-x[1])\ncy=0\nhq=[]\nfor a,b,c in ABC[:y]:\n cy+=b\n heappush(hq,b-c)\nLy=[cy]\nfor a,b,c in ABC[y:y+z]:\n cy+=b-heappushpop(hq,b-c)\n Ly.append(cy)\ncx=0\nhq=[]\nfor a,b,c in ABC[y+z:]:\n cx+=a\n heappush(hq,a-c)\nLx=[cx]\nfor a,b,c in reversed(ABC[y:y+z]):\n cx+=a-heappushpop(hq,a-c)\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\nABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]\nABC.sort(key=lambda x: x[0]-x[1])\ncy=0\nhq=[]\nfor a,b,c in ABC[:y]:\n cy+=b\n heappush(hq,b-c)\nLy=[cy]\nfor a,b,c in ABC[y:y+z]:\n cy+=b-heappushpop(hq,b-c)\n Ly.append(cy)\ncx=0\nhq=[]\nfor a,b,c in ABC[y+z:]:\n cx+=a\n heappush(hq,a-c)\nLx=[cx]\nfor a,b,c in reversed(ABC[y:y+z]):\n cx+=a-heappushpop(hq,a-c)\n Lx.append(cx)\n", "import sys\ninput=sys.stdin.readline\nfrom heapq import heappush,heappushpop\nx,y,z=map(int,input().split())\nABC=[tuple(map(int,input().split())) for _ in range(x+y+z)]\nABC.sort(key=lambda x: x[0]-x[1])\ncy=0\nhq=[]\nfor a,b,c in ABC[:y]:\n cy+=b\n heappush(hq,b-c)\nLy=[cy]\nfor a,b,c in ABC[y:y+z]:\n cy+=b-heappushpop(hq,b-c)\n Ly.append(cy)\ncx=0\nhq=[]\nfor a,b,c in ABC[y+z:]:\n cx+=a\n heappush(hq,a-c)\nLx=[cx]\nfor a,b,c in reversed(ABC[y:y+z]):\n cx+=a-heappushpop(hq,a-c)\n Lx.append(cx)\nprint(max(i+j for i,j in zip(Lx[::-1],Ly)))\n" ]
17
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "uq = []\ncy = 0\n\n\nlq = []\ncx = 0\n", "import sys\n\n\nuq = []\ncy = 0\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\n\n\nuq = []\ncy = 0\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\n\n\nuq = []\ncy = 0\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n \n cy += y\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\n\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n \n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor x, y, z in xyz[-X:]:\n \n cx += x\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor x, y, z in xyz[-X:]:\n heappush(lq, x - z)\n cx += x\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor x, y, z in xyz[-X:]:\n heappush(lq, x - z)\n cx += x\nLx = [cx]\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor x, y, z in xyz[-X:]:\n heappush(lq, x - z)\n cx += x\nLx = [cx]\nfor x, y, z in xyz[Y+Z-1:Y-1:-1]:\n cx += x - heappushpop(lq, x - z)\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor x, y, z in xyz[-X:]:\n heappush(lq, x - z)\n cx += x\nLx = [cx]\nfor x, y, z in xyz[Y+Z-1:Y-1:-1]:\n cx += x - heappushpop(lq, x - z)\n Lx += [cx]\n", "import sys\nfrom heapq import heappush, heappushpop\nX, Y, Z = map(int, input().split())\nxyz = sorted([list(map(int,l.split()))for l in sys.stdin],key=lambda x:x[0]-x[1])\n\nuq = []\ncy = 0\nfor x, y, z in xyz[:Y]:\n heappush(uq, y - z)\n cy += y\nLy = [cy]\nfor x, y, z in xyz[Y:Y+Z]:\n cy += y - heappushpop(uq, y - z)\n Ly += [cy]\n\nlq = []\ncx = 0\nfor x, y, z in xyz[-X:]:\n heappush(lq, x - z)\n cx += x\nLx = [cx]\nfor x, y, z in xyz[Y+Z-1:Y-1:-1]:\n cx += x - heappushpop(lq, x - z)\n Lx += [cx]\n\nprint(max(map(sum, zip(Lx, Ly[::-1]))))\n" ]
17
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "ABC = []\n\n\n#金側\n\nq = []\n\nnow = 0\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\n\nABC = []\n\n\n#金側\n\nq = []\n\nnow = 0\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\n\nABC = []\n\n\n#金側\n\nq = []\n\nnow = 0\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\n\n\n#金側\n\nq = []\n\nnow = 0\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n \n\n#金側\n\nq = []\n\nnow = 0\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\n\n#金側\n\nq = []\n\nnow = 0\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\n\nnow = 0\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n \n \n now += a\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n \n now += a\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n \n \n now += a\n \n \n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n \n now += a\n \n \n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n \n \n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n \n \n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n \n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\n\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\n\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n \n \n now += b\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n \n now += b\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\nansY.append(now)\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\nansY.append(now)\n\nfor i in range(Y,Y+Z):\n \n \n now += b\n \n \n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\nansY.append(now)\n\nfor i in range(Y,Y+Z):\n tmp,a,b,c = ABC[i]\n \n now += b\n \n \n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\nansY.append(now)\n\nfor i in range(Y,Y+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\n \n \n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\nansY.append(now)\n\nfor i in range(Y,Y+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\n pp = heapq.heappop( q )\n \n \n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\nansY.append(now)\n\nfor i in range(Y,Y+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\n pp = heapq.heappop( q )\n now -= pp\n \n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\nansY.append(now)\n\nfor i in range(Y,Y+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\n pp = heapq.heappop( q )\n now -= pp\n ansY.append(now)\n\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\nansY.append(now)\n\nfor i in range(Y,Y+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\n pp = heapq.heappop( q )\n now -= pp\n ansY.append(now)\n\nansY.reverse()\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\nansY.append(now)\n\nfor i in range(Y,Y+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\n pp = heapq.heappop( q )\n now -= pp\n ansY.append(now)\n\nansY.reverse()\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\nfor i in range(len(ansX)):\n ans = max(ans , ansX[i] + ansY[i])\n", "\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\nansY.append(now)\n\nfor i in range(Y,Y+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\n pp = heapq.heappop( q )\n now -= pp\n ansY.append(now)\n\nansY.reverse()\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\nfor i in range(len(ansX)):\n ans = max(ans , ansX[i] + ansY[i])\nprint (ans)\n", "\n\"\"\"\n\nhttps://atcoder.jp/contests/agc018/tasks/agc018_c\n\n絶対最大なのは、全員から一番たくさん持ってるコインを貰う事\nとりあえずそうして、後から人数を調整することを考える\n\n金と銀を貰いすぎたとする\n金をN個減らす、銀をM個減らす、銅をN+M個増やす…?\n→必ずしもこうではなさそう…\n金を貰いすぎたとする。\n貰いすぎたコインを減らし、別のコインを増やす\n削った時の減少量が銀にするとA-B , 銅だとA-C\n減少量最小化問題になる\n→あれなんかやったことがある気が…?\n\n方針違う?\n適当にX,Y,Z人で振り分ける\nswapすると増える限りswapし続ける?\n\n金銀でswapする場合(1が金→銀)\n(B1-A1) + (A2-B2)増える\nどちらもheapqに突っ込んで、正な限りswapし続ける?\n金銀・金銅・銀銅でやれば最適解になるか?\n→そんなことはない(改善できない局所解がある…)\n\nなんもわからん…\n\n\n=====ちょっと答えを見た=====\n\nまず銅を無視する(金銀だけに分ける)\nA-Bで降順ソート(B-A)で昇順ソート\nここで金銀グループはどこかで切って左右にすっぱり分けられる\nその中で金銅・銀銅を同様に求めればよい?\n→ヒープを使って切り方を全探索\n\nまずX個金・Y+Z個銀グループにしたとする\n→銀グループは B-Cで昇順ソート小さいほうからZ個の和*-1 + 大きいほうからY個の和が現在の解\n\n左からX個金・右からZ個銅にして、ずらしていって解を求める\nX側では、a-c をヒープに入れ、最小のやつを取り除いて-1をかけて寄与に足せばいい\nZ側では逆\n\n1WA → はい???\nb-aでソートしたとき同じものをどうするか\n\n1 1 1\n1 2 1\n99 100 1\n1 1 10000\n→102\n\nだめなケース見つけたわ\n最後のとこだった\n\"\"\"\n\nimport heapq\nX,Y,Z = map(int,input().split())\nABC = []\nfor i in range(X+Y+Z):\n a,b,c = map(int,input().split())\n ABC.append( (b-a , a,b,c) )\n\nABC.sort()\n\n#金側\n\nq = []\nansX = []\nnow = 0\nfor i in range(X):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\nansX.append(now)\n\nfor i in range(X,X+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , a-c )\n now += a\n pp = heapq.heappop( q )\n now -= pp\n ansX.append(now)\n\n#銀側\nABC.reverse()\n\nq = []\nansY = []\nnow = 0\nfor i in range(Y):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\nansY.append(now)\n\nfor i in range(Y,Y+Z):\n tmp,a,b,c = ABC[i]\n heapq.heappush( q , b-c )\n now += b\n pp = heapq.heappop( q )\n now -= pp\n ansY.append(now)\n\nansY.reverse()\n\n#print (ABC)\n#print (ansX,ansY)\n\nans = 0\nfor i in range(len(ansX)):\n ans = max(ans , ansX[i] + ansY[i])\nprint (ans)\n" ]
35
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "gsb = []\n", "import heapq\n\ngsb = []\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n ans_gb.append(gb_total_delta)\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n ans_gb.append(gb_total_delta)\nans_sb = [0]\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n ans_gb.append(gb_total_delta)\nans_sb = [0]\nsb_total_delta = 0\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n ans_gb.append(gb_total_delta)\nans_sb = [0]\nsb_total_delta = 0\nfor a, b, c in gsb[x:x+z][::-1]:\n new_sb = b - c\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n ans_gb.append(gb_total_delta)\nans_sb = [0]\nsb_total_delta = 0\nfor a, b, c in gsb[x:x+z][::-1]:\n new_sb = b - c\n small_sb = heapq.heappushpop(sb_pq, new_sb)\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n ans_gb.append(gb_total_delta)\nans_sb = [0]\nsb_total_delta = 0\nfor a, b, c in gsb[x:x+z][::-1]:\n new_sb = b - c\n small_sb = heapq.heappushpop(sb_pq, new_sb)\n sb_total_delta += new_sb - small_sb\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n ans_gb.append(gb_total_delta)\nans_sb = [0]\nsb_total_delta = 0\nfor a, b, c in gsb[x:x+z][::-1]:\n new_sb = b - c\n small_sb = heapq.heappushpop(sb_pq, new_sb)\n sb_total_delta += new_sb - small_sb\n ans_sb.append(sb_total_delta)\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n ans_gb.append(gb_total_delta)\nans_sb = [0]\nsb_total_delta = 0\nfor a, b, c in gsb[x:x+z][::-1]:\n new_sb = b - c\n small_sb = heapq.heappushpop(sb_pq, new_sb)\n sb_total_delta += new_sb - small_sb\n ans_sb.append(sb_total_delta)\nans_sb.reverse()\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n ans_gb.append(gb_total_delta)\nans_sb = [0]\nsb_total_delta = 0\nfor a, b, c in gsb[x:x+z][::-1]:\n new_sb = b - c\n small_sb = heapq.heappushpop(sb_pq, new_sb)\n sb_total_delta += new_sb - small_sb\n ans_sb.append(sb_total_delta)\nans_sb.reverse()\n\nmax_delta = 0\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n ans_gb.append(gb_total_delta)\nans_sb = [0]\nsb_total_delta = 0\nfor a, b, c in gsb[x:x+z][::-1]:\n new_sb = b - c\n small_sb = heapq.heappushpop(sb_pq, new_sb)\n sb_total_delta += new_sb - small_sb\n ans_sb.append(sb_total_delta)\nans_sb.reverse()\n\nmax_delta = 0\nfor gb, sb in zip(ans_gb, ans_sb):\n max_delta = max(max_delta, gb + sb)\n", "import heapq\nx, y, z = [int(item) for item in input().split()]\ngsb = []\nfor i in range(x + y + z):\n gsb.append([int(item) for item in input().split()])\ngsb.sort(key=lambda x: x[0] - x[1], reverse=True)\n\ng_sum = sum(item[0] for item in gsb[:x])\ns_sum = sum(item[1] for item in gsb[x+z:x+y+z])\nb_sum = sum(item[2] for item in gsb[x:x+z])\n\ngb_pq = [a - c for a, b, c in gsb[:x]]\nsb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]\nheapq.heapify(gb_pq)\nheapq.heapify(sb_pq)\n\nans_gb = [0]\ngb_total_delta = 0\nfor a, b, c in gsb[x:x+z]:\n new_gb = a - c\n small_gb = heapq.heappushpop(gb_pq, new_gb)\n gb_total_delta += new_gb - small_gb\n ans_gb.append(gb_total_delta)\nans_sb = [0]\nsb_total_delta = 0\nfor a, b, c in gsb[x:x+z][::-1]:\n new_sb = b - c\n small_sb = heapq.heappushpop(sb_pq, new_sb)\n sb_total_delta += new_sb - small_sb\n ans_sb.append(sb_total_delta)\nans_sb.reverse()\n\nmax_delta = 0\nfor gb, sb in zip(ans_gb, ans_sb):\n max_delta = max(max_delta, gb + sb)\nprint(g_sum + s_sum + b_sum + max_delta)\n" ]
29
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n \n \n yq = []\n tr = 0\n \n \n xq = []\n tr = 0\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n \n \n yq = []\n tr = 0\n \n \n xq = []\n tr = 0\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n \n yq = []\n tr = 0\n \n \n xq = []\n tr = 0\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n \n \n xq = []\n tr = 0\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n \n tr += y\n \n \n xq = []\n tr = 0\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n \n \n xq = []\n tr = 0\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n \n\n xq = []\n tr = 0\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n \n\n xq = []\n tr = 0\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n \n xq = []\n tr = 0\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n \n tr += x\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n heapq.heappush(xq, x-z)\n tr += x\n \n \n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n heapq.heappush(xq, x-z)\n tr += x\n xa = [tr]\n \n\n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n heapq.heappush(xq, x-z)\n tr += x\n xa = [tr]\n for i in range(Z):\n \n tr += x\n \n \n tr -= t\n \n\n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n heapq.heappush(xq, x-z)\n tr += x\n xa = [tr]\n for i in range(Z):\n x,y,z = xyz[-X-i-1]\n tr += x\n \n \n tr -= t\n \n\n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n heapq.heappush(xq, x-z)\n tr += x\n xa = [tr]\n for i in range(Z):\n x,y,z = xyz[-X-i-1]\n tr += x\n heapq.heappush(xq, x-z)\n \n tr -= t\n \n\n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n heapq.heappush(xq, x-z)\n tr += x\n xa = [tr]\n for i in range(Z):\n x,y,z = xyz[-X-i-1]\n tr += x\n heapq.heappush(xq, x-z)\n t = heapq.heappop(xq)\n tr -= t\n \n\n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n heapq.heappush(xq, x-z)\n tr += x\n xa = [tr]\n for i in range(Z):\n x,y,z = xyz[-X-i-1]\n tr += x\n heapq.heappush(xq, x-z)\n t = heapq.heappop(xq)\n tr -= t\n xa.append(tr)\n\n r = 0\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n heapq.heappush(xq, x-z)\n tr += x\n xa = [tr]\n for i in range(Z):\n x,y,z = xyz[-X-i-1]\n tr += x\n heapq.heappush(xq, x-z)\n t = heapq.heappop(xq)\n tr -= t\n xa.append(tr)\n\n r = 0\n for a,b in zip(ya, xa[::-1]):\n tr = a+b\n \n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n heapq.heappush(xq, x-z)\n tr += x\n xa = [tr]\n for i in range(Z):\n x,y,z = xyz[-X-i-1]\n tr += x\n heapq.heappush(xq, x-z)\n t = heapq.heappop(xq)\n tr -= t\n xa.append(tr)\n\n r = 0\n for a,b in zip(ya, xa[::-1]):\n tr = a+b\n if r < tr:\n r = tr\n\n return r\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n heapq.heappush(xq, x-z)\n tr += x\n xa = [tr]\n for i in range(Z):\n x,y,z = xyz[-X-i-1]\n tr += x\n heapq.heappush(xq, x-z)\n t = heapq.heappop(xq)\n tr -= t\n xa.append(tr)\n\n r = 0\n for a,b in zip(ya, xa[::-1]):\n tr = a+b\n if r < tr:\n r = tr\n\n return r\n\n\nprint(main())\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n X,Y,Z = LI()\n xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])\n ys = xyz[:Y]\n yq = []\n tr = 0\n for x,y,z in ys:\n heapq.heappush(yq, y-z)\n tr += y\n ya = [tr]\n for i in range(Z):\n x,y,z = xyz[Y+i]\n tr += y\n heapq.heappush(yq, y-z)\n t = heapq.heappop(yq)\n tr -= t\n ya.append(tr)\n\n xs = xyz[Y+Z:]\n xq = []\n tr = 0\n for x,y,z in xs:\n heapq.heappush(xq, x-z)\n tr += x\n xa = [tr]\n for i in range(Z):\n x,y,z = xyz[-X-i-1]\n tr += x\n heapq.heappush(xq, x-z)\n t = heapq.heappop(xq)\n tr -= t\n xa.append(tr)\n\n r = 0\n for a,b in zip(ya, xa[::-1]):\n tr = a+b\n if r < tr:\n r = tr\n\n return r\n\n\n\n\nprint(main())\n" ]
38
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "import heapq\n", "import heapq\n\n\ndef main():\n \n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n \n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n \n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n \n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n \n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n \n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n \n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n \n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n \n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n \n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[Y+i][1] - P[Y+i][2])\n \n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[Y+i][1] - P[Y+i][2])\n lsum[i+1] = lsum[i] - heapq.heappop(h) + P[Y+i][1]\n # print(lsum)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[Y+i][1] - P[Y+i][2])\n lsum[i+1] = lsum[i] - heapq.heappop(h) + P[Y+i][1]\n # print(lsum)\n rsum = [0] * (Z+1)\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[Y+i][1] - P[Y+i][2])\n lsum[i+1] = lsum[i] - heapq.heappop(h) + P[Y+i][1]\n # print(lsum)\n rsum = [0] * (Z+1)\n rsum[0] = sum(map(lambda x: x[0], P[N-X:]))\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[Y+i][1] - P[Y+i][2])\n lsum[i+1] = lsum[i] - heapq.heappop(h) + P[Y+i][1]\n # print(lsum)\n rsum = [0] * (Z+1)\n rsum[0] = sum(map(lambda x: x[0], P[N-X:]))\n h = list(map(lambda x: x[0] - x[2], P[N-X:]))\n \n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[Y+i][1] - P[Y+i][2])\n lsum[i+1] = lsum[i] - heapq.heappop(h) + P[Y+i][1]\n # print(lsum)\n rsum = [0] * (Z+1)\n rsum[0] = sum(map(lambda x: x[0], P[N-X:]))\n h = list(map(lambda x: x[0] - x[2], P[N-X:]))\n heapq.heapify(h)\n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[Y+i][1] - P[Y+i][2])\n lsum[i+1] = lsum[i] - heapq.heappop(h) + P[Y+i][1]\n # print(lsum)\n rsum = [0] * (Z+1)\n rsum[0] = sum(map(lambda x: x[0], P[N-X:]))\n h = list(map(lambda x: x[0] - x[2], P[N-X:]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[N-X-1-i][0] - P[N-X-1-i][2])\n \n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[Y+i][1] - P[Y+i][2])\n lsum[i+1] = lsum[i] - heapq.heappop(h) + P[Y+i][1]\n # print(lsum)\n rsum = [0] * (Z+1)\n rsum[0] = sum(map(lambda x: x[0], P[N-X:]))\n h = list(map(lambda x: x[0] - x[2], P[N-X:]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[N-X-1-i][0] - P[N-X-1-i][2])\n rsum[i+1] = rsum[i] - heapq.heappop(h) + P[N-X-1-i][0]\n # print(rsum)\n ans = 0\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[Y+i][1] - P[Y+i][2])\n lsum[i+1] = lsum[i] - heapq.heappop(h) + P[Y+i][1]\n # print(lsum)\n rsum = [0] * (Z+1)\n rsum[0] = sum(map(lambda x: x[0], P[N-X:]))\n h = list(map(lambda x: x[0] - x[2], P[N-X:]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[N-X-1-i][0] - P[N-X-1-i][2])\n rsum[i+1] = rsum[i] - heapq.heappop(h) + P[N-X-1-i][0]\n # print(rsum)\n ans = 0\n for i in range(Z+1):\n ans = max(lsum[i] + rsum[Z-i], ans)\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[Y+i][1] - P[Y+i][2])\n lsum[i+1] = lsum[i] - heapq.heappop(h) + P[Y+i][1]\n # print(lsum)\n rsum = [0] * (Z+1)\n rsum[0] = sum(map(lambda x: x[0], P[N-X:]))\n h = list(map(lambda x: x[0] - x[2], P[N-X:]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[N-X-1-i][0] - P[N-X-1-i][2])\n rsum[i+1] = rsum[i] - heapq.heappop(h) + P[N-X-1-i][0]\n # print(rsum)\n ans = 0\n for i in range(Z+1):\n ans = max(lsum[i] + rsum[Z-i], ans)\n print(ans)\n", "import heapq\n\n\ndef main():\n X, Y, Z = map(int, input().split())\n N = X+Y+Z\n P = [None] * N\n for i in range(N):\n A, B, C = map(int, input().split())\n P[i] = (A, B, C)\n P.sort(key=lambda x: x[0] - x[1])\n lsum = [0] * (Z+1)\n lsum[0] = sum(map(lambda x: x[1], P[:Y]))\n h = list(map(lambda x: x[1] - x[2], P[:Y]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[Y+i][1] - P[Y+i][2])\n lsum[i+1] = lsum[i] - heapq.heappop(h) + P[Y+i][1]\n # print(lsum)\n rsum = [0] * (Z+1)\n rsum[0] = sum(map(lambda x: x[0], P[N-X:]))\n h = list(map(lambda x: x[0] - x[2], P[N-X:]))\n heapq.heapify(h)\n for i in range(Z):\n heapq.heappush(h, P[N-X-1-i][0] - P[N-X-1-i][2])\n rsum[i+1] = rsum[i] - heapq.heappop(h) + P[N-X-1-i][0]\n # print(rsum)\n ans = 0\n for i in range(Z+1):\n ans = max(lsum[i] + rsum[Z-i], ans)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n" ]
24
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L.append(L[i]+A[i][1]);heappush(q1,A[i][1]-A[i][2]);R.append(R[i]+A[N-1-i][0]);\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L.append(L[i]+A[i][1]);heappush(q1,A[i][1]-A[i][2]);R.append(R[i]+A[N-1-i][0]);heappush(q2,A[N-1-i][0]-A[N-1-i][2])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L.append(L[i]+A[i][1]);heappush(q1,A[i][1]-A[i][2]);R.append(R[i]+A[N-1-i][0]);heappush(q2,A[N-1-i][0]-A[N-1-i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L.append(L[i]+A[i][1]);heappush(q1,A[i][1]-A[i][2]);R.append(R[i]+A[N-1-i][0]);heappush(q2,A[N-1-i][0]-A[N-1-i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n if i>=X:R[i+1]-=heappop(q2)\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L.append(L[i]+A[i][1]);heappush(q1,A[i][1]-A[i][2]);R.append(R[i]+A[N-1-i][0]);heappush(q2,A[N-1-i][0]-A[N-1-i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n if i>=X:R[i+1]-=heappop(q2)\nprint(max(L[i]+R[N-i] for i in range(Y,N-X+1)))\n" ]
9
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "import heapq\n", "import heapq\n\nif __name__ == '__main__':\n \n A = []\n B = []\n C = []\n \n \n # print(gold_minus_silver)\n\n # 左側\n \n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n \n \n # print(gold_minus_silver)\n\n # 左側\n \n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n \n\n # print(gold_minus_silver)\n\n # 左側\n \n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n \n \n # print(gold_minus_silver)\n\n # 左側\n \n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n \n \n # print(gold_minus_silver)\n\n # 左側\n \n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n \n\n # print(gold_minus_silver)\n\n # 左側\n \n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n \n # print(gold_minus_silver)\n\n # 左側\n \n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n \n # print(gold_minus_silver)\n\n # 左側\n \n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n \n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n \n\n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n \n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n \n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n \n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n \n \n # print(left_max)\n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n \n \n # print(left_max)\n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n \n\n # print(left_max)\n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n right_side = []\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n right_side = []\n for i in range(Y + Z, N):\n heapq.heappush(right_side, (gold_minus_silver[i][1] - gold_minus_silver[i][3], gold_minus_silver[i][1],\n gold_minus_silver[i][3]))\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n right_side = []\n for i in range(Y + Z, N):\n heapq.heappush(right_side, (gold_minus_silver[i][1] - gold_minus_silver[i][3], gold_minus_silver[i][1],\n gold_minus_silver[i][3]))\n right_max = [0 for i in range(Z + 1)]\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n right_side = []\n for i in range(Y + Z, N):\n heapq.heappush(right_side, (gold_minus_silver[i][1] - gold_minus_silver[i][3], gold_minus_silver[i][1],\n gold_minus_silver[i][3]))\n right_max = [0 for i in range(Z + 1)]\n for i in range(0, X):\n right_max[Z] += right_side[i][1]\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n right_side = []\n for i in range(Y + Z, N):\n heapq.heappush(right_side, (gold_minus_silver[i][1] - gold_minus_silver[i][3], gold_minus_silver[i][1],\n gold_minus_silver[i][3]))\n right_max = [0 for i in range(Z + 1)]\n for i in range(0, X):\n right_max[Z] += right_side[i][1]\n right_bronze = []\n \n\n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n right_side = []\n for i in range(Y + Z, N):\n heapq.heappush(right_side, (gold_minus_silver[i][1] - gold_minus_silver[i][3], gold_minus_silver[i][1],\n gold_minus_silver[i][3]))\n right_max = [0 for i in range(Z + 1)]\n for i in range(0, X):\n right_max[Z] += right_side[i][1]\n right_bronze = []\n for K in range(Z - 1, -1, -1):\n heapq.heappush(right_side, (gold_minus_silver[K + Y][1] - gold_minus_silver[K + Y][3],\n gold_minus_silver[K + Y][1],\n gold_minus_silver[K + Y][3]))\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n right_side = []\n for i in range(Y + Z, N):\n heapq.heappush(right_side, (gold_minus_silver[i][1] - gold_minus_silver[i][3], gold_minus_silver[i][1],\n gold_minus_silver[i][3]))\n right_max = [0 for i in range(Z + 1)]\n for i in range(0, X):\n right_max[Z] += right_side[i][1]\n right_bronze = []\n for K in range(Z - 1, -1, -1):\n heapq.heappush(right_side, (gold_minus_silver[K + Y][1] - gold_minus_silver[K + Y][3],\n gold_minus_silver[K + Y][1],\n gold_minus_silver[K + Y][3]))\n right_max[K] = right_max[K + 1] + gold_minus_silver[K + Y][1]\n \n \n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n right_side = []\n for i in range(Y + Z, N):\n heapq.heappush(right_side, (gold_minus_silver[i][1] - gold_minus_silver[i][3], gold_minus_silver[i][1],\n gold_minus_silver[i][3]))\n right_max = [0 for i in range(Z + 1)]\n for i in range(0, X):\n right_max[Z] += right_side[i][1]\n right_bronze = []\n for K in range(Z - 1, -1, -1):\n heapq.heappush(right_side, (gold_minus_silver[K + Y][1] - gold_minus_silver[K + Y][3],\n gold_minus_silver[K + Y][1],\n gold_minus_silver[K + Y][3]))\n right_max[K] = right_max[K + 1] + gold_minus_silver[K + Y][1]\n bronze = heapq.heappop(right_side)\n \n\n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n right_side = []\n for i in range(Y + Z, N):\n heapq.heappush(right_side, (gold_minus_silver[i][1] - gold_minus_silver[i][3], gold_minus_silver[i][1],\n gold_minus_silver[i][3]))\n right_max = [0 for i in range(Z + 1)]\n for i in range(0, X):\n right_max[Z] += right_side[i][1]\n right_bronze = []\n for K in range(Z - 1, -1, -1):\n heapq.heappush(right_side, (gold_minus_silver[K + Y][1] - gold_minus_silver[K + Y][3],\n gold_minus_silver[K + Y][1],\n gold_minus_silver[K + Y][3]))\n right_max[K] = right_max[K + 1] + gold_minus_silver[K + Y][1]\n bronze = heapq.heappop(right_side)\n right_max[K] += (bronze[2] - bronze[1])\n\n # print(right_max)\n\n ans = 0\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n right_side = []\n for i in range(Y + Z, N):\n heapq.heappush(right_side, (gold_minus_silver[i][1] - gold_minus_silver[i][3], gold_minus_silver[i][1],\n gold_minus_silver[i][3]))\n right_max = [0 for i in range(Z + 1)]\n for i in range(0, X):\n right_max[Z] += right_side[i][1]\n right_bronze = []\n for K in range(Z - 1, -1, -1):\n heapq.heappush(right_side, (gold_minus_silver[K + Y][1] - gold_minus_silver[K + Y][3],\n gold_minus_silver[K + Y][1],\n gold_minus_silver[K + Y][3]))\n right_max[K] = right_max[K + 1] + gold_minus_silver[K + Y][1]\n bronze = heapq.heappop(right_side)\n right_max[K] += (bronze[2] - bronze[1])\n\n # print(right_max)\n\n ans = 0\n for i in range(0, Z + 1):\n if ans < left_max[i] + right_max[i]:\n ans = left_max[i] + right_max[i]\n", "import heapq\n\nif __name__ == '__main__':\n X, Y, Z = list(map(int, input().split()))\n A = []\n B = []\n C = []\n N = X + Y + Z\n for i in range(N):\n tmp_a, tmp_b, tmp_c = list(map(int, input().split()))\n A.append(tmp_a)\n B.append(tmp_b)\n C.append(tmp_c)\n\n gold_minus_silver = [(a - b, a, b, c) for (a, b, c) in zip(A, B, C)]\n gold_minus_silver.sort()\n # print(gold_minus_silver)\n\n # 左側\n left_side = []\n for i in range(0, Y):\n heapq.heappush(left_side, (\n gold_minus_silver[i][2] - gold_minus_silver[i][3], gold_minus_silver[i][2], gold_minus_silver[i][3]))\n\n left_max = [0 for i in range(Z + 1)]\n for i in range(0, Y):\n left_max[0] += left_side[i][1]\n left_bronze = []\n for K in range(1, Z + 1):\n heapq.heappush(left_side, (gold_minus_silver[K + Y - 1][2] - gold_minus_silver[K + Y - 1][3],\n gold_minus_silver[K + Y - 1][2],\n gold_minus_silver[K + Y - 1][3]))\n left_max[K] = left_max[K - 1] + gold_minus_silver[K + Y - 1][2]\n bronze = heapq.heappop(left_side)\n left_max[K] += (bronze[2] - bronze[1])\n\n\n # print(left_max)\n # 右側\n right_side = []\n for i in range(Y + Z, N):\n heapq.heappush(right_side, (gold_minus_silver[i][1] - gold_minus_silver[i][3], gold_minus_silver[i][1],\n gold_minus_silver[i][3]))\n right_max = [0 for i in range(Z + 1)]\n for i in range(0, X):\n right_max[Z] += right_side[i][1]\n right_bronze = []\n for K in range(Z - 1, -1, -1):\n heapq.heappush(right_side, (gold_minus_silver[K + Y][1] - gold_minus_silver[K + Y][3],\n gold_minus_silver[K + Y][1],\n gold_minus_silver[K + Y][3]))\n right_max[K] = right_max[K + 1] + gold_minus_silver[K + Y][1]\n bronze = heapq.heappop(right_side)\n right_max[K] += (bronze[2] - bronze[1])\n\n # print(right_max)\n\n ans = 0\n for i in range(0, Z + 1):\n if ans < left_max[i] + right_max[i]:\n ans = left_max[i] + right_max[i]\n\n print(ans)\n" ]
31
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];p=[];q=[];L=[0];R=[0]\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];p=[];q=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];p=[];q=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];p=[];q=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(p,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];p=[];q=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(p,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q,A[~i][0]-A[~i][2])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];p=[];q=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(p,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q,A[~i][0]-A[~i][2])\n if i>=Y:L[i+1]-=heappop(p)\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];p=[];q=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(p,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q,A[~i][0]-A[~i][2])\n if i>=Y:L[i+1]-=heappop(p)\n if i>=X:R[i+1]-=heappop(q)\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];p=[];q=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(p,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q,A[~i][0]-A[~i][2])\n if i>=Y:L[i+1]-=heappop(p)\n if i>=X:R[i+1]-=heappop(q)\nprint(max(L[i]+R[~i]for i in range(Y,N-X+1)))\n" ]
9
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "from heapq import heapify, heappushpop\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n\nP = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n\nP = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])\n\nG = sum(t[0] for t in P[-X:])\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n\nP = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])\n\nG = sum(t[0] for t in P[-X:])\nS = sum(t[1] for t in P[:Y])\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n\nP = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])\n\nG = sum(t[0] for t in P[-X:])\nS = sum(t[1] for t in P[:Y])\nC = sum(t[2] for t in P[Y:-X])\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n\nP = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])\n\nG = sum(t[0] for t in P[-X:])\nS = sum(t[1] for t in P[:Y])\nC = sum(t[2] for t in P[Y:-X])\n\nQg = [a - c for a, b, c in P[-X:]]\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n\nP = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])\n\nG = sum(t[0] for t in P[-X:])\nS = sum(t[1] for t in P[:Y])\nC = sum(t[2] for t in P[Y:-X])\n\nQg = [a - c for a, b, c in P[-X:]]\nheapify(Qg)\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n\nP = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])\n\nG = sum(t[0] for t in P[-X:])\nS = sum(t[1] for t in P[:Y])\nC = sum(t[2] for t in P[Y:-X])\n\nQg = [a - c for a, b, c in P[-X:]]\nheapify(Qg)\nB = [0] + [a - c - heappushpop(Qg, a - c) for a, b, c in reversed(P[Y:-X])]\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n\nP = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])\n\nG = sum(t[0] for t in P[-X:])\nS = sum(t[1] for t in P[:Y])\nC = sum(t[2] for t in P[Y:-X])\n\nQg = [a - c for a, b, c in P[-X:]]\nheapify(Qg)\nB = [0] + [a - c - heappushpop(Qg, a - c) for a, b, c in reversed(P[Y:-X])]\n\nQs = [b - c for a, b, c in P[:Y]]\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n\nP = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])\n\nG = sum(t[0] for t in P[-X:])\nS = sum(t[1] for t in P[:Y])\nC = sum(t[2] for t in P[Y:-X])\n\nQg = [a - c for a, b, c in P[-X:]]\nheapify(Qg)\nB = [0] + [a - c - heappushpop(Qg, a - c) for a, b, c in reversed(P[Y:-X])]\n\nQs = [b - c for a, b, c in P[:Y]]\nheapify(Qs)\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n\nP = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])\n\nG = sum(t[0] for t in P[-X:])\nS = sum(t[1] for t in P[:Y])\nC = sum(t[2] for t in P[Y:-X])\n\nQg = [a - c for a, b, c in P[-X:]]\nheapify(Qg)\nB = [0] + [a - c - heappushpop(Qg, a - c) for a, b, c in reversed(P[Y:-X])]\n\nQs = [b - c for a, b, c in P[:Y]]\nheapify(Qs)\nF = [0] + [b - c - heappushpop(Qs, b - c) for a, b, c in P[Y:-X]]\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nX, Y, Z, *ABC = map(int, open(0).read().split())\n\nP = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])\n\nG = sum(t[0] for t in P[-X:])\nS = sum(t[1] for t in P[:Y])\nC = sum(t[2] for t in P[Y:-X])\n\nQg = [a - c for a, b, c in P[-X:]]\nheapify(Qg)\nB = [0] + [a - c - heappushpop(Qg, a - c) for a, b, c in reversed(P[Y:-X])]\n\nQs = [b - c for a, b, c in P[:Y]]\nheapify(Qs)\nF = [0] + [b - c - heappushpop(Qs, b - c) for a, b, c in P[Y:-X]]\n\nprint(G + S + C + max(a + b for a, b in zip(accumulate(F), reversed(list(accumulate(B))))))\n" ]
15
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "ans = 0\n", "import heapq\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n \n \nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n \n \nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n \n \nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n \n \nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n \n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\ngold = bronze = 0\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\ngold = bronze = 0\nq_gb = []\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\ngold = bronze = 0\nq_gb = []\nheapq.heapify(q_gb)\n\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\ngold = bronze = 0\nq_gb = []\nheapq.heapify(q_gb)\nfor i,(g,s,b) in enumerate(reversed(src)):\n heapq.heappush(q_gb, (g-b, g, b))\n \n \nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\ngold = bronze = 0\nq_gb = []\nheapq.heapify(q_gb)\nfor i,(g,s,b) in enumerate(reversed(src)):\n heapq.heappush(q_gb, (g-b, g, b))\n gold += g\n \n \nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\ngold = bronze = 0\nq_gb = []\nheapq.heapify(q_gb)\nfor i,(g,s,b) in enumerate(reversed(src)):\n heapq.heappush(q_gb, (g-b, g, b))\n gold += g\n if i >= X:\n _, g2, b2 = heapq.heappop(q_gb)\n \n \nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\ngold = bronze = 0\nq_gb = []\nheapq.heapify(q_gb)\nfor i,(g,s,b) in enumerate(reversed(src)):\n heapq.heappush(q_gb, (g-b, g, b))\n gold += g\n if i >= X:\n _, g2, b2 = heapq.heappop(q_gb)\n gold -= g2\n \n \nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\ngold = bronze = 0\nq_gb = []\nheapq.heapify(q_gb)\nfor i,(g,s,b) in enumerate(reversed(src)):\n heapq.heappush(q_gb, (g-b, g, b))\n gold += g\n if i >= X:\n _, g2, b2 = heapq.heappop(q_gb)\n gold -= g2\n bronze += b2\n \n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\ngold = bronze = 0\nq_gb = []\nheapq.heapify(q_gb)\nfor i,(g,s,b) in enumerate(reversed(src)):\n heapq.heappush(q_gb, (g-b, g, b))\n gold += g\n if i >= X:\n _, g2, b2 = heapq.heappop(q_gb)\n gold -= g2\n bronze += b2\n r_opt[N-1-i] = gold + bronze\n\nans = 0\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\ngold = bronze = 0\nq_gb = []\nheapq.heapify(q_gb)\nfor i,(g,s,b) in enumerate(reversed(src)):\n heapq.heappush(q_gb, (g-b, g, b))\n gold += g\n if i >= X:\n _, g2, b2 = heapq.heappop(q_gb)\n gold -= g2\n bronze += b2\n r_opt[N-1-i] = gold + bronze\n\nans = 0\nfor l,r in list(zip(l_opt, r_opt))[Y:Y+Z+1]:\n ans = max(ans, l+r)\n", "import heapq\nX,Y,Z = map(int,input().split())\nN = X+Y+Z\nsrc = [tuple(map(int,input().split())) for i in range(N)]\nsrc.sort(key=lambda x:x[0]-x[1])\n\nl_opt = [0]*(N+1)\nr_opt = [0]*(N+1)\n\nsilver = bronze = 0\nq_sb = []\nheapq.heapify(q_sb)\nfor i,(g,s,b) in enumerate(src):\n heapq.heappush(q_sb, (s-b, s, b))\n silver += s\n if i >= Y:\n _, s2, b2 = heapq.heappop(q_sb)\n silver -= s2\n bronze += b2\n l_opt[i+1] = silver + bronze\n\ngold = bronze = 0\nq_gb = []\nheapq.heapify(q_gb)\nfor i,(g,s,b) in enumerate(reversed(src)):\n heapq.heappush(q_gb, (g-b, g, b))\n gold += g\n if i >= X:\n _, g2, b2 = heapq.heappop(q_gb)\n gold -= g2\n bronze += b2\n r_opt[N-1-i] = gold + bronze\n\nans = 0\nfor l,r in list(zip(l_opt, r_opt))[Y:Y+Z+1]:\n ans = max(ans, l+r)\nprint(ans)\n" ]
29
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "sb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\n\n\nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\n\n\nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\n\n\nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\n\n\nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\n\n\nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\n\n\nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n \n \nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n \n \nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n \n\nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\n\nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\n\n\nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\n\nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n \n \ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n \n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n \n \ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n \n \ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n \n \ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n \n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\n\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\ngold = [0] * (Z + 1)\ngb = []\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\ngold = [0] * (Z + 1)\ngb = []\nfor i in range(X):\n j = gs[i][1]\n \n \nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\ngold = [0] * (Z + 1)\ngb = []\nfor i in range(X):\n j = gs[i][1]\n heappush(gb, (A[j] - C[j], j))\n \n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\ngold = [0] * (Z + 1)\ngb = []\nfor i in range(X):\n j = gs[i][1]\n heappush(gb, (A[j] - C[j], j))\n gold[0] += A[j]\n\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\ngold = [0] * (Z + 1)\ngb = []\nfor i in range(X):\n j = gs[i][1]\n heappush(gb, (A[j] - C[j], j))\n gold[0] += A[j]\n\nfor i in range(Z):\n j = gs[i + X][1]\n \n \nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\ngold = [0] * (Z + 1)\ngb = []\nfor i in range(X):\n j = gs[i][1]\n heappush(gb, (A[j] - C[j], j))\n gold[0] += A[j]\n\nfor i in range(Z):\n j = gs[i + X][1]\n heappush(gb, (A[j] - C[j], j))\n \n \nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\ngold = [0] * (Z + 1)\ngb = []\nfor i in range(X):\n j = gs[i][1]\n heappush(gb, (A[j] - C[j], j))\n gold[0] += A[j]\n\nfor i in range(Z):\n j = gs[i + X][1]\n heappush(gb, (A[j] - C[j], j))\n gold[i + 1] += gold[i] + A[j]\n \n \nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\ngold = [0] * (Z + 1)\ngb = []\nfor i in range(X):\n j = gs[i][1]\n heappush(gb, (A[j] - C[j], j))\n gold[0] += A[j]\n\nfor i in range(Z):\n j = gs[i + X][1]\n heappush(gb, (A[j] - C[j], j))\n gold[i + 1] += gold[i] + A[j]\n k = heappop(gb)\n \n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\ngold = [0] * (Z + 1)\ngb = []\nfor i in range(X):\n j = gs[i][1]\n heappush(gb, (A[j] - C[j], j))\n gold[0] += A[j]\n\nfor i in range(Z):\n j = gs[i + X][1]\n heappush(gb, (A[j] - C[j], j))\n gold[i + 1] += gold[i] + A[j]\n k = heappop(gb)\n gold[i + 1] -= k[0]\n\nans = 0\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\ngold = [0] * (Z + 1)\ngb = []\nfor i in range(X):\n j = gs[i][1]\n heappush(gb, (A[j] - C[j], j))\n gold[0] += A[j]\n\nfor i in range(Z):\n j = gs[i + X][1]\n heappush(gb, (A[j] - C[j], j))\n gold[i + 1] += gold[i] + A[j]\n k = heappop(gb)\n gold[i + 1] -= k[0]\n\nans = 0\nfor i in range(Z + 1):\n ans = max(ans, silver[i] + gold[Z - i])\n", "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\nX, Y, Z = map(int, input().split())\nN = X + Y + Z\nA, B, C = [], [], []\nfor i in range(N):\n a, b, c = map(int, input().split())\n A.append(a)\n B.append(b)\n C.append(c)\n\ngs = [(A[i] - B[i], i) for i in range(N)]\ngs = sorted(gs)\n\nsilver = [0] * (Z + 1)\n\nsb = []\nfor i in range(Y):\n j = gs[i][1]\n heappush(sb, (B[j] - C[j], j))\n silver[0] += B[j]\n\nfor i in range(Z):\n j = gs[i + Y][1]\n heappush(sb, (B[j] - C[j], j))\n silver[i + 1] += silver[i] + B[j]\n k = heappop(sb)\n silver[i + 1] -= k[0]\n\ngs = sorted(gs, reverse=True)\ngold = [0] * (Z + 1)\ngb = []\nfor i in range(X):\n j = gs[i][1]\n heappush(gb, (A[j] - C[j], j))\n gold[0] += A[j]\n\nfor i in range(Z):\n j = gs[i + X][1]\n heappush(gb, (A[j] - C[j], j))\n gold[i + 1] += gold[i] + A[j]\n k = heappop(gb)\n gold[i + 1] -= k[0]\n\nans = 0\nfor i in range(Z + 1):\n ans = max(ans, silver[i] + gold[Z - i])\n\nprint(ans)\n" ]
35
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[-1-i][0]-A[-1-i][2])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[-1-i][0]-A[-1-i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[-1-i][0]-A[-1-i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n if i>=X:R[i+1]-=heappop(q2)\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[-1-i][0]];heappush(q2,A[-1-i][0]-A[-1-i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n if i>=X:R[i+1]-=heappop(q2)\nprint(max(L[i]+R[N-i] for i in range(Y,N-X+1)))\n" ]
9
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[N-1-i][0]];\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[N-1-i][0]];heappush(q2,A[N-1-i][0]-A[N-1-i][2])\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[N-1-i][0]];heappush(q2,A[N-1-i][0]-A[N-1-i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[N-1-i][0]];heappush(q2,A[N-1-i][0]-A[N-1-i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n if i>=X:R[i+1]-=heappop(q2)\n", "from heapq import*\nX,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]\nfor _ in[0]*N:A.append([int(e)for e in input().split()])\nA.sort(key=lambda a:a[0]-a[1])\nfor i in range(N):\n L+=[L[i]+A[i][1]];heappush(q1,A[i][1]-A[i][2]);R+=[R[i]+A[N-1-i][0]];heappush(q2,A[N-1-i][0]-A[N-1-i][2])\n if i>=Y:L[i+1]-=heappop(q1)\n if i>=X:R[i+1]-=heappop(q2)\nprint(max(L[i]+R[N-i] for i in range(Y,N-X+1)))\n" ]
9
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "xls = []\nansx = 0\n\nyls = []\nansy = 0\n", "from heapq import heappush,heappop\n\n\nxls = []\nansx = 0\n\nyls = []\nansy = 0\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\n\n\nxls = []\nansx = 0\n\nyls = []\nansy = 0\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\n\n\nxls = []\nansx = 0\n\nyls = []\nansy = 0\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\n\nxls = []\nansx = 0\n\nyls = []\nansy = 0\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\n\nyls = []\nansy = 0\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\nfor i in range(x):\n a,b,c = abc[i]\n \n \nyls = []\nansy = 0\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\nfor i in range(x):\n a,b,c = abc[i]\n heappush(xls,(a-c,i))\n \nyls = []\nansy = 0\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\nfor i in range(x):\n a,b,c = abc[i]\n heappush(xls,(a-c,i))\n ansx += a\nyls = []\nansy = 0\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\nfor i in range(x):\n a,b,c = abc[i]\n heappush(xls,(a-c,i))\n ansx += a\nyls = []\nansy = 0\nfor i in range(n-y,n):\n a,b,c = abc[i]\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\nfor i in range(x):\n a,b,c = abc[i]\n heappush(xls,(a-c,i))\n ansx += a\nyls = []\nansy = 0\nfor i in range(n-y,n):\n a,b,c = abc[i]\n heappush(yls,(b-c,i))\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\nfor i in range(x):\n a,b,c = abc[i]\n heappush(xls,(a-c,i))\n ansx += a\nyls = []\nansy = 0\nfor i in range(n-y,n):\n a,b,c = abc[i]\n heappush(yls,(b-c,i))\n ansy += b\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\nfor i in range(x):\n a,b,c = abc[i]\n heappush(xls,(a-c,i))\n ansx += a\nyls = []\nansy = 0\nfor i in range(n-y,n):\n a,b,c = abc[i]\n heappush(yls,(b-c,i))\n ansy += b\nansls = [[0 for i in range(2)] for j in range(z+1)]\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\nfor i in range(x):\n a,b,c = abc[i]\n heappush(xls,(a-c,i))\n ansx += a\nyls = []\nansy = 0\nfor i in range(n-y,n):\n a,b,c = abc[i]\n heappush(yls,(b-c,i))\n ansy += b\nansls = [[0 for i in range(2)] for j in range(z+1)]\nansls[0][0] = ansx\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\nfor i in range(x):\n a,b,c = abc[i]\n heappush(xls,(a-c,i))\n ansx += a\nyls = []\nansy = 0\nfor i in range(n-y,n):\n a,b,c = abc[i]\n heappush(yls,(b-c,i))\n ansy += b\nansls = [[0 for i in range(2)] for j in range(z+1)]\nansls[0][0] = ansx\nansls[-1][1] = ansy\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\nfor i in range(x):\n a,b,c = abc[i]\n heappush(xls,(a-c,i))\n ansx += a\nyls = []\nansy = 0\nfor i in range(n-y,n):\n a,b,c = abc[i]\n heappush(yls,(b-c,i))\n ansy += b\nansls = [[0 for i in range(2)] for j in range(z+1)]\nansls[0][0] = ansx\nansls[-1][1] = ansy\nfor d,ls,w,ans in (0,xls,range(x,x+z),ansx),(1,yls,(range(n-y-1,x-1,-1)),ansy):\n for i in w:\n a,b,c = abc[i]\n if d == 0:\n heappush(ls,(a-c,i))\n else:\n heappush(ls,(b-c,i))\n p,q = heappop(ls)\n ans += -p\n if d == 0:\n ans += a\n ansls[i-x+1][0] = ans\n else:\n ans += b\n ansls[i-n+y+z][1] = ans\n", "from heapq import heappush,heappop\nx,y,z = map(int,input().split())\nn = x+y+z\nabc = [list(map(int,input().split())) for i in range(n)]\nabc.sort(key = lambda t:t[0]-t[1],reverse=True)\nxls = []\nansx = 0\nfor i in range(x):\n a,b,c = abc[i]\n heappush(xls,(a-c,i))\n ansx += a\nyls = []\nansy = 0\nfor i in range(n-y,n):\n a,b,c = abc[i]\n heappush(yls,(b-c,i))\n ansy += b\nansls = [[0 for i in range(2)] for j in range(z+1)]\nansls[0][0] = ansx\nansls[-1][1] = ansy\nfor d,ls,w,ans in (0,xls,range(x,x+z),ansx),(1,yls,(range(n-y-1,x-1,-1)),ansy):\n for i in w:\n a,b,c = abc[i]\n if d == 0:\n heappush(ls,(a-c,i))\n else:\n heappush(ls,(b-c,i))\n p,q = heappop(ls)\n ans += -p\n if d == 0:\n ans += a\n ansls[i-x+1][0] = ans\n else:\n ans += b\n ansls[i-n+y+z][1] = ans\nprint(max([sum(ansls[i]) for i in range(z+1)]))\n" ]
18
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "PQ = []\n\n\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\n\nPQ = []\n\n\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\n\n\nPQ = []\n\n\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\n\n\nPQ = []\n\n\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\n\nPQ = []\n\n\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\n\nPQ = []\n\n\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\n\nPQ = []\n\n\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\n\n\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n \n \nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n \n \nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n \n \nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n \n \nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n \n \nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n \n \nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n \n\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\n\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\n\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\n\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\nfor i in reversed(range(W)):\n A, B, C = ABCs[i]\n \n \nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\nfor i in reversed(range(W)):\n A, B, C = ABCs[i]\n heappush(PQ, (A-C, i))\n \n \nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\nfor i in reversed(range(W)):\n A, B, C = ABCs[i]\n heappush(PQ, (A-C, i))\n sumA += A\n \n \nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\nfor i in reversed(range(W)):\n A, B, C = ABCs[i]\n heappush(PQ, (A-C, i))\n sumA += A\n if len(PQ) > X:\n _, j = heappop(PQ)\n \n \nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\nfor i in reversed(range(W)):\n A, B, C = ABCs[i]\n heappush(PQ, (A-C, i))\n sumA += A\n if len(PQ) > X:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n \n \nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\nfor i in reversed(range(W)):\n A, B, C = ABCs[i]\n heappush(PQ, (A-C, i))\n sumA += A\n if len(PQ) > X:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumA -= A\n \n \nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\nfor i in reversed(range(W)):\n A, B, C = ABCs[i]\n heappush(PQ, (A-C, i))\n sumA += A\n if len(PQ) > X:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumA -= A\n sumC += C\n \n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\nfor i in reversed(range(W)):\n A, B, C = ABCs[i]\n heappush(PQ, (A-C, i))\n sumA += A\n if len(PQ) > X:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumA -= A\n sumC += C\n sumACs[i] = sumA+sumC\n\nans = 0\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\nfor i in reversed(range(W)):\n A, B, C = ABCs[i]\n heappush(PQ, (A-C, i))\n sumA += A\n if len(PQ) > X:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumA -= A\n sumC += C\n sumACs[i] = sumA+sumC\n\nans = 0\nfor i in range(Y-1, W-X):\n sumABC = sumBCs[i] + sumACs[i+1]\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\nfor i in reversed(range(W)):\n A, B, C = ABCs[i]\n heappush(PQ, (A-C, i))\n sumA += A\n if len(PQ) > X:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumA -= A\n sumC += C\n sumACs[i] = sumA+sumC\n\nans = 0\nfor i in range(Y-1, W-X):\n sumABC = sumBCs[i] + sumACs[i+1]\n ans = max(ans, sumABC)\n", "from heapq import heapify, heappush, heappop\n\nX, Y, Z = map(int, input().split())\nW = X+Y+Z\nABCs = [tuple(map(int, input().split())) for _ in range(W)]\n\nABCs.sort(key=lambda x: x[0]-x[1])\n\nsumBCs = [0] * W\nsumB = sumC = 0\nPQ = []\nfor i in range(W):\n A, B, C = ABCs[i]\n heappush(PQ, (B-C, i))\n sumB += B\n if len(PQ) > Y:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumB -= B\n sumC += C\n sumBCs[i] = sumB+sumC\n\nsumACs = [0] * W\nsumA = sumC = 0\nPQ = []\nfor i in reversed(range(W)):\n A, B, C = ABCs[i]\n heappush(PQ, (A-C, i))\n sumA += A\n if len(PQ) > X:\n _, j = heappop(PQ)\n A, B, C = ABCs[j]\n sumA -= A\n sumC += C\n sumACs[i] = sumA+sumC\n\nans = 0\nfor i in range(Y-1, W-X):\n sumABC = sumBCs[i] + sumACs[i+1]\n ans = max(ans, sumABC)\n\nprint(ans)\n" ]
30
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\n\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\n\n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\n\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\n\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\n\n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\n\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\n\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\n\n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\n\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\n\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\n\n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\n\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\n\n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\n\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\n\n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\n\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\n\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\n\n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\n\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\n\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\n\n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\n\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\n\n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\n\n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n \n \n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n \n \n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n \n \n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n \n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n AC[i] = S\n\n# B or Cで、BをY個とるルール\n\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n AC[i] = S\n\n# B or Cで、BをY個とるルール\nBC = [0] * (X+Y+Z)\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n AC[i] = S\n\n# B or Cで、BをY個とるルール\nBC = [0] * (X+Y+Z)\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC[::-1]):\n S += b\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n AC[i] = S\n\n# B or Cで、BをY個とるルール\nBC = [0] * (X+Y+Z)\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC[::-1]):\n S += b\n d = b - c\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n AC[i] = S\n\n# B or Cで、BをY個とるルール\nBC = [0] * (X+Y+Z)\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC[::-1]):\n S += b\n d = b - c\n if len(q) < Y:\n heappush(q,d)\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n AC[i] = S\n\n# B or Cで、BをY個とるルール\nBC = [0] * (X+Y+Z)\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC[::-1]):\n S += b\n d = b - c\n if len(q) < Y:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n AC[i] = S\n\n# B or Cで、BをY個とるルール\nBC = [0] * (X+Y+Z)\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC[::-1]):\n S += b\n d = b - c\n if len(q) < Y:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n BC[i] = S\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n AC[i] = S\n\n# B or Cで、BをY個とるルール\nBC = [0] * (X+Y+Z)\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC[::-1]):\n S += b\n d = b - c\n if len(q) < Y:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n BC[i] = S\nBC = BC[::-1]\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n AC[i] = S\n\n# B or Cで、BをY個とるルール\nBC = [0] * (X+Y+Z)\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC[::-1]):\n S += b\n d = b - c\n if len(q) < Y:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n BC[i] = S\nBC = BC[::-1]\n\nanswer = max(x+y for x,y in zip(AC[X-1:X+Z],BC[X:]))\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom heapq import heappop, heappush, heappushpop\n\nX,Y,Z = map(int,readline().split())\nm = map(int,read().split())\nABC = sorted(zip(m,m,m), key = lambda x: x[1] - x[0])\n\n# 手前は A or C, 後半はB or Cでとるようにする\n\n# A or Cで、AをX個とるルール\nAC = [0] * (X+Y+Z)\nq = [] # a -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC):\n S += a\n d = a - c\n if len(q) < X:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n AC[i] = S\n\n# B or Cで、BをY個とるルール\nBC = [0] * (X+Y+Z)\nq = [] # b -> cと変更する利点をマイナスで格納する\nS = 0\nfor i,(a,b,c) in enumerate(ABC[::-1]):\n S += b\n d = b - c\n if len(q) < Y:\n heappush(q,d)\n else:\n S -= heappushpop(q,d)\n BC[i] = S\nBC = BC[::-1]\n\nanswer = max(x+y for x,y in zip(AC[X-1:X+Z],BC[X:]))\nprint(answer)\n" ]
25
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "from heapq import heapify, heappushpop\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n\nans_f = [0]\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n\nans_f = [0]\nfor a, b, c in persons[y:-x]:\n np = b - c\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n\nans_f = [0]\nfor a, b, c in persons[y:-x]:\n np = b - c\n rp = heappushpop(silver_pq, np)\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n\nans_f = [0]\nfor a, b, c in persons[y:-x]:\n np = b - c\n rp = heappushpop(silver_pq, np)\n ans_f.append(np - rp)\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n\nans_f = [0]\nfor a, b, c in persons[y:-x]:\n np = b - c\n rp = heappushpop(silver_pq, np)\n ans_f.append(np - rp)\n\nans_b = [0]\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n\nans_f = [0]\nfor a, b, c in persons[y:-x]:\n np = b - c\n rp = heappushpop(silver_pq, np)\n ans_f.append(np - rp)\n\nans_b = [0]\nfor a, b, c in persons[-x - 1:y - 1:-1]:\n np = a - c\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n\nans_f = [0]\nfor a, b, c in persons[y:-x]:\n np = b - c\n rp = heappushpop(silver_pq, np)\n ans_f.append(np - rp)\n\nans_b = [0]\nfor a, b, c in persons[-x - 1:y - 1:-1]:\n np = a - c\n rp = heappushpop(gold_pq, np)\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n\nans_f = [0]\nfor a, b, c in persons[y:-x]:\n np = b - c\n rp = heappushpop(silver_pq, np)\n ans_f.append(np - rp)\n\nans_b = [0]\nfor a, b, c in persons[-x - 1:y - 1:-1]:\n np = a - c\n rp = heappushpop(gold_pq, np)\n ans_b.append(np - rp)\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n\nans_f = [0]\nfor a, b, c in persons[y:-x]:\n np = b - c\n rp = heappushpop(silver_pq, np)\n ans_f.append(np - rp)\n\nans_b = [0]\nfor a, b, c in persons[-x - 1:y - 1:-1]:\n np = a - c\n rp = heappushpop(gold_pq, np)\n ans_b.append(np - rp)\n\nans_f = list(accumulate(ans_f))\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n\nans_f = [0]\nfor a, b, c in persons[y:-x]:\n np = b - c\n rp = heappushpop(silver_pq, np)\n ans_f.append(np - rp)\n\nans_b = [0]\nfor a, b, c in persons[-x - 1:y - 1:-1]:\n np = a - c\n rp = heappushpop(gold_pq, np)\n ans_b.append(np - rp)\n\nans_f = list(accumulate(ans_f))\nans_b = list(accumulate(ans_b))\n", "from heapq import heapify, heappushpop\nfrom itertools import accumulate\n\nx, y, z = map(int, input().split())\npersons = [list(map(int, input().split())) for _ in range(x + y + z)]\npersons.sort(key=lambda abc: abc[0] - abc[1])\n\nans_g = sum(x[0] for x in persons[-x:])\nans_s = sum(x[1] for x in persons[:y])\nans_c = sum(x[2] for x in persons[y:-x])\n\ngold_pq = [a - c for a, b, c in persons[-x:]]\nsilver_pq = [b - c for a, b, c in persons[:y]]\nheapify(gold_pq)\nheapify(silver_pq)\n\nans_f = [0]\nfor a, b, c in persons[y:-x]:\n np = b - c\n rp = heappushpop(silver_pq, np)\n ans_f.append(np - rp)\n\nans_b = [0]\nfor a, b, c in persons[-x - 1:y - 1:-1]:\n np = a - c\n rp = heappushpop(gold_pq, np)\n ans_b.append(np - rp)\n\nans_f = list(accumulate(ans_f))\nans_b = list(accumulate(ans_b))\nprint(ans_g + ans_s + ans_c + max(sum(z) for z in zip(ans_f, reversed(ans_b))))\n" ]
24
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "q = []\n\n\nq = []\n", "import sys\n\n\nq = []\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\n\nq = []\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\nq = []\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\n\nq = []\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\n\n\nq = []\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\n\nq = []\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n \n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n \n \nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n \n \nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n \n \nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n \n \nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n \n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\n\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\nB = [0] * (Z+1)\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\nB = [0] * (Z+1)\nRC = [0] * (Z+1)\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\nB = [0] * (Z+1)\nRC = [0] * (Z+1)\nB[0] += sum_b\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\nB = [0] * (Z+1)\nRC = [0] * (Z+1)\nB[0] += sum_b\nfor i,(a,b,c) in enumerate(ABC_rev[Y:Y+Z],1):\n sum_b += b\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\nB = [0] * (Z+1)\nRC = [0] * (Z+1)\nB[0] += sum_b\nfor i,(a,b,c) in enumerate(ABC_rev[Y:Y+Z],1):\n sum_b += b\n x,del_b = heappushpop(q,(b-c,b))\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\nB = [0] * (Z+1)\nRC = [0] * (Z+1)\nB[0] += sum_b\nfor i,(a,b,c) in enumerate(ABC_rev[Y:Y+Z],1):\n sum_b += b\n x,del_b = heappushpop(q,(b-c,b))\n sum_b -= del_b\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\nB = [0] * (Z+1)\nRC = [0] * (Z+1)\nB[0] += sum_b\nfor i,(a,b,c) in enumerate(ABC_rev[Y:Y+Z],1):\n sum_b += b\n x,del_b = heappushpop(q,(b-c,b))\n sum_b -= del_b\n sum_c += del_b-x\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\nB = [0] * (Z+1)\nRC = [0] * (Z+1)\nB[0] += sum_b\nfor i,(a,b,c) in enumerate(ABC_rev[Y:Y+Z],1):\n sum_b += b\n x,del_b = heappushpop(q,(b-c,b))\n sum_b -= del_b\n sum_c += del_b-x\n B[i] = sum_b\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\nB = [0] * (Z+1)\nRC = [0] * (Z+1)\nB[0] += sum_b\nfor i,(a,b,c) in enumerate(ABC_rev[Y:Y+Z],1):\n sum_b += b\n x,del_b = heappushpop(q,(b-c,b))\n sum_b -= del_b\n sum_c += del_b-x\n B[i] = sum_b\n RC[i] = sum_c\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\nB = [0] * (Z+1)\nRC = [0] * (Z+1)\nB[0] += sum_b\nfor i,(a,b,c) in enumerate(ABC_rev[Y:Y+Z],1):\n sum_b += b\n x,del_b = heappushpop(q,(b-c,b))\n sum_b -= del_b\n sum_c += del_b-x\n B[i] = sum_b\n RC[i] = sum_c\n\nanswer = max(sum(x) for x in zip(A,LC,B[::-1],RC[::-1]))\n", "import sys\ninput = sys.stdin.readline\n\nfrom heapq import heappush, heappushpop\n\n\"\"\"\n銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる\n逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択\n\n最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる\n\"\"\"\n\nX,Y,Z = map(int,input().split())\nABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]\n\nABC.sort(key = lambda x: x[0]-x[1],reverse=True)\n\nq = []\nsum_a = 0\nsum_c = 0\nfor a,b,c in ABC[:X]:\n # 金を入れる。銅-金の優先度\n heappush(q,(a-c,a))\n sum_a += a\nA = [0] * (Z+1)\nLC = [0] * (Z+1)\nA[0] = sum_a\nfor i,(a,b,c) in enumerate(ABC[X:X+Z],1):\n sum_a += a\n x,del_a = heappushpop(q,(a-c,a))\n sum_a -= del_a\n sum_c += del_a-x\n A[i] = sum_a\n LC[i] = sum_c\n\nABC_rev = ABC[::-1]\nq = []\nsum_b = 0\nsum_c = 0\nfor a,b,c in ABC_rev[:Y]:\n heappush(q,(b-c,b))\n sum_b += b\nB = [0] * (Z+1)\nRC = [0] * (Z+1)\nB[0] += sum_b\nfor i,(a,b,c) in enumerate(ABC_rev[Y:Y+Z],1):\n sum_b += b\n x,del_b = heappushpop(q,(b-c,b))\n sum_b -= del_b\n sum_c += del_b-x\n B[i] = sum_b\n RC[i] = sum_c\n\nanswer = max(sum(x) for x in zip(A,LC,B[::-1],RC[::-1]))\nprint(answer)\n" ]
38
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "tmp = 0\nl = []\n\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\n\n\ntmp = 0\nl = []\n\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\n\n\ntmp = 0\nl = []\n\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\n\ntmp = 0\nl = []\n\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\n\n\ntmp = 0\nl = []\n\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\n\n\ntmp = 0\nl = []\n\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\n\ntmp = 0\nl = []\n\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\n\n\ntmp = 0\nl = []\n\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\n\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n \n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n \n \ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n \n \ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n \n \ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n \n \ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n \n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\nfor i in range(x+z, x+y+z):\n tmp += c[i][1]\n \n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\nfor i in range(x+z, x+y+z):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\nfor i in range(x+z, x+y+z):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\nans_r[x+z] = tmp\n\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\nfor i in range(x+z, x+y+z):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\nans_r[x+z] = tmp\n\nfor i in range(x+z-1, x-1, -1):\n tmp += c[i][1]\n \n \nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\nfor i in range(x+z, x+y+z):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\nans_r[x+z] = tmp\n\nfor i in range(x+z-1, x-1, -1):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\n \n \nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\nfor i in range(x+z, x+y+z):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\nans_r[x+z] = tmp\n\nfor i in range(x+z-1, x-1, -1):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\n p = heappop(r)\n \n \nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\nfor i in range(x+z, x+y+z):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\nans_r[x+z] = tmp\n\nfor i in range(x+z-1, x-1, -1):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\n p = heappop(r)\n tmp -= c[p[1]][1]\n \n \nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\nfor i in range(x+z, x+y+z):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\nans_r[x+z] = tmp\n\nfor i in range(x+z-1, x-1, -1):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\n p = heappop(r)\n tmp -= c[p[1]][1]\n tmp += c[p[1]][2]\n \n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\nfor i in range(x+z, x+y+z):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\nans_r[x+z] = tmp\n\nfor i in range(x+z-1, x-1, -1):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\n p = heappop(r)\n tmp -= c[p[1]][1]\n tmp += c[p[1]][2]\n ans_r[i] = tmp\n\nans = 0\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\nfor i in range(x+z, x+y+z):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\nans_r[x+z] = tmp\n\nfor i in range(x+z-1, x-1, -1):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\n p = heappop(r)\n tmp -= c[p[1]][1]\n tmp += c[p[1]][2]\n ans_r[i] = tmp\n\nans = 0\nfor i in range(x, x+z+1):\n ans = max(ans, ans_l[i] + ans_r[i])\n", "import sys\ndef input():\n return sys.stdin.buffer.readline()[:-1]\nfrom heapq import heappush, heappop\n\nx, y, z = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(x+y+z)]\nc.sort(key=lambda x: x[1]-x[0])\n\nans_l = [-1 for _ in range(x+y+z)]\nans_r = [-1 for _ in range(x+y+z)]\n\ntmp = 0\nl = []\nfor i in range(x):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\nans_l[x] = tmp\n\nfor i in range(x, x+z):\n tmp += c[i][0]\n heappush(l, (c[i][0] - c[i][2], i))\n p = heappop(l)\n tmp -= c[p[1]][0]\n tmp += c[p[1]][2]\n ans_l[i+1] = tmp\n\ntmp = 0\nr = []\nfor i in range(x+z, x+y+z):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\nans_r[x+z] = tmp\n\nfor i in range(x+z-1, x-1, -1):\n tmp += c[i][1]\n heappush(r, (c[i][1] - c[i][2], i))\n p = heappop(r)\n tmp -= c[p[1]][1]\n tmp += c[p[1]][2]\n ans_r[i] = tmp\n\nans = 0\nfor i in range(x, x+z+1):\n ans = max(ans, ans_l[i] + ans_r[i])\n\nprint(ans)\n" ]
30
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\n\n\ny=[0]*N\nS=0\nn=0\nque=[]\n\n\nx=[0]*N\nS=0\nn=0\nque=[]\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\n\ny=[0]*N\nS=0\nn=0\nque=[]\n\n\nx=[0]*N\nS=0\nn=0\nque=[]\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\n\n\nx=[0]*N\nS=0\nn=0\nque=[]\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n \n\nx=[0]*N\nS=0\nn=0\nque=[]\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n \n S+=val\n n+=1\n y[i]=S\n \n\nx=[0]*N\nS=0\nn=0\nque=[]\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n \n\nx=[0]*N\nS=0\nn=0\nque=[]\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n \n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n \n \n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n \n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N-1,-1,-1):\n val=coin[i][0]-coin[i][2]\n \n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N-1,-1,-1):\n val=coin[i][0]-coin[i][2]\n if X>n:\n \n S+=val\n n+=1\n x[i]=S\n \n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N-1,-1,-1):\n val=coin[i][0]-coin[i][2]\n if X>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n x[i]=S\n \n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N-1,-1,-1):\n val=coin[i][0]-coin[i][2]\n if X>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n x[i]=S\n else:\n \n x[i]=S\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N-1,-1,-1):\n val=coin[i][0]-coin[i][2]\n if X>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n x[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n \n \n x[i]=S\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N-1,-1,-1):\n val=coin[i][0]-coin[i][2]\n if X>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n x[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n \n x[i]=S\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N-1,-1,-1):\n val=coin[i][0]-coin[i][2]\n if X>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n x[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n x[i]=S\n\n\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N-1,-1,-1):\n val=coin[i][0]-coin[i][2]\n if X>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n x[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n x[i]=S\n\nbase=sum(coin[i][2] for i in range(N))\nans=-1\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N-1,-1,-1):\n val=coin[i][0]-coin[i][2]\n if X>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n x[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n x[i]=S\n\nbase=sum(coin[i][2] for i in range(N))\nans=-1\nfor i in range(N):\n if i>=Y-1 and N-(i+1)>=X:\n temp=base+x[i+1]+y[i]\n ans=max(ans,temp)\n", "import heapq,sys\n\ninput=sys.stdin.readline\n\nX,Y,Z=map(int,input().split())\nN=X+Y+Z\ncoin=[tuple(map(int,input().split())) for i in range(N)]\ncoin.sort(key=lambda x:x[0]-x[1])\ny=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N):\n val=coin[i][1]-coin[i][2]\n if Y>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n y[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n y[i]=S\n\nx=[0]*N\nS=0\nn=0\nque=[]\nfor i in range(N-1,-1,-1):\n val=coin[i][0]-coin[i][2]\n if X>n:\n heapq.heappush(que,val)\n S+=val\n n+=1\n x[i]=S\n else:\n if que[0]<val:\n S+=val-que[0]\n heapq.heappop(que)\n heapq.heappush(que,val)\n x[i]=S\n\nbase=sum(coin[i][2] for i in range(N))\nans=-1\nfor i in range(N):\n if i>=Y-1 and N-(i+1)>=X:\n temp=base+x[i+1]+y[i]\n ans=max(ans,temp)\nprint(ans)\n" ]
21
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different colors of coins from a single person. On the other hand, a person will give all of his/her coins of the color specified by Snuke. Snuke would like to maximize the total number of coins of all colors he gets. Find the maximum possible number of coins. Constraints * 1 \leq X * 1 \leq Y * 1 \leq Z * X+Y+Z \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^9 * 1 \leq C_i \leq 10^9 Input Input is given from Standard Input in the following format: X Y Z A_1 B_1 C_1 A_2 B_2 C_2 : A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z} Output Print the maximum possible total number of coins of all colors he gets. Examples Input 1 2 1 2 4 4 3 2 1 7 6 7 5 2 3 Output 18 Input 3 3 2 16 17 1 2 7 5 2 16 12 17 7 7 13 2 10 12 18 3 16 15 19 5 6 2 Output 110 Input 6 2 4 33189 87907 277349742 71616 46764 575306520 8801 53151 327161251 58589 4337 796697686 66854 17565 289910583 50598 35195 478112689 13919 88414 103962455 7953 69657 699253752 44255 98144 468443709 2332 42580 752437097 39752 19060 845062869 60126 74101 382963164 Output 3093929975
[ "\n", "ans = 0\nBC = []\n\n\nq = []\nan = 0\n\nA = [an]\n\nq = []\nan = 0\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\n\n\nq = []\nan = 0\n\nA = [an]\n\nq = []\nan = 0\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n \n\nq = []\nan = 0\n\nA = [an]\n\nq = []\nan = 0\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\n\n\nq = []\nan = 0\n\nA = [an]\n\nq = []\nan = 0\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\n\nq = []\nan = 0\n\nA = [an]\n\nq = []\nan = 0\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\nimport heapq\nq = []\nan = 0\n\nA = [an]\n\nq = []\nan = 0\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\nimport heapq\nq = []\nan = 0\nfor b, _ in BC[:Y]:\n \n an += b\nA = [an]\n\nq = []\nan = 0\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\nimport heapq\nq = []\nan = 0\nfor b, _ in BC[:Y]:\n heapq.heappush(q, b)\n an += b\nA = [an]\n\nq = []\nan = 0\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\nimport heapq\nq = []\nan = 0\nfor b, _ in BC[:Y]:\n heapq.heappush(q, b)\n an += b\nA = [an]\nfor b, _ in BC[Y:-Z]:\n heapq.heappush(q, b)\n an += b\n b_ = heapq.heappop(q)\n an -= b_\n \nq = []\nan = 0\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\nimport heapq\nq = []\nan = 0\nfor b, _ in BC[:Y]:\n heapq.heappush(q, b)\n an += b\nA = [an]\nfor b, _ in BC[Y:-Z]:\n heapq.heappush(q, b)\n an += b\n b_ = heapq.heappop(q)\n an -= b_\n A.append(an)\nq = []\nan = 0\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\nimport heapq\nq = []\nan = 0\nfor b, _ in BC[:Y]:\n heapq.heappush(q, b)\n an += b\nA = [an]\nfor b, _ in BC[Y:-Z]:\n heapq.heappush(q, b)\n an += b\n b_ = heapq.heappop(q)\n an -= b_\n A.append(an)\nq = []\nan = 0\nfor _, c in BC[-Z:]:\n \n an += c\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\nimport heapq\nq = []\nan = 0\nfor b, _ in BC[:Y]:\n heapq.heappush(q, b)\n an += b\nA = [an]\nfor b, _ in BC[Y:-Z]:\n heapq.heappush(q, b)\n an += b\n b_ = heapq.heappop(q)\n an -= b_\n A.append(an)\nq = []\nan = 0\nfor _, c in BC[-Z:]:\n heapq.heappush(q, c)\n an += c\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\nimport heapq\nq = []\nan = 0\nfor b, _ in BC[:Y]:\n heapq.heappush(q, b)\n an += b\nA = [an]\nfor b, _ in BC[Y:-Z]:\n heapq.heappush(q, b)\n an += b\n b_ = heapq.heappop(q)\n an -= b_\n A.append(an)\nq = []\nan = 0\nfor _, c in BC[-Z:]:\n heapq.heappush(q, c)\n an += c\nA[-1] += an\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\nimport heapq\nq = []\nan = 0\nfor b, _ in BC[:Y]:\n heapq.heappush(q, b)\n an += b\nA = [an]\nfor b, _ in BC[Y:-Z]:\n heapq.heappush(q, b)\n an += b\n b_ = heapq.heappop(q)\n an -= b_\n A.append(an)\nq = []\nan = 0\nfor _, c in BC[-Z:]:\n heapq.heappush(q, c)\n an += c\nA[-1] += an\nfor i, (_, c) in enumerate(BC[-Z-1:Y-1:-1], 2):\n heapq.heappush(q, c)\n an += c\n c_ = heapq.heappop(q)\n an -= c_\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\nimport heapq\nq = []\nan = 0\nfor b, _ in BC[:Y]:\n heapq.heappush(q, b)\n an += b\nA = [an]\nfor b, _ in BC[Y:-Z]:\n heapq.heappush(q, b)\n an += b\n b_ = heapq.heappop(q)\n an -= b_\n A.append(an)\nq = []\nan = 0\nfor _, c in BC[-Z:]:\n heapq.heappush(q, c)\n an += c\nA[-1] += an\nfor i, (_, c) in enumerate(BC[-Z-1:Y-1:-1], 2):\n heapq.heappush(q, c)\n an += c\n c_ = heapq.heappop(q)\n an -= c_\n A[-i] += an\n", "X, Y, Z = map(int, input().split())\nans = 0\nBC = []\nfor _ in range(X+Y+Z):\n a, b, c = map(int, input().split())\n ans += a\n BC.append([b-a, c-a])\nBC.sort(key=lambda x: x[1]-x[0])\nimport heapq\nq = []\nan = 0\nfor b, _ in BC[:Y]:\n heapq.heappush(q, b)\n an += b\nA = [an]\nfor b, _ in BC[Y:-Z]:\n heapq.heappush(q, b)\n an += b\n b_ = heapq.heappop(q)\n an -= b_\n A.append(an)\nq = []\nan = 0\nfor _, c in BC[-Z:]:\n heapq.heappush(q, c)\n an += c\nA[-1] += an\nfor i, (_, c) in enumerate(BC[-Z-1:Y-1:-1], 2):\n heapq.heappush(q, c)\n an += c\n c_ = heapq.heappop(q)\n an -= c_\n A[-i] += an\nprint(ans + max(A))\n" ]
17
[ { "input": "1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3", "output": "18" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929975" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "110" } ]
[ { "input": "1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "output": "18\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093929146\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n16 15 19\n5 6 2", "output": "111\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093891435\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 13\n12 18 3\n22 15 19\n5 6 2", "output": "113\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093871658\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n22 15 19\n5 6 2", "output": "110\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 2\n5 3 3", "output": "17\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n5 6 2", "output": "105\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "2872505176\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872513114\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775302590\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775315312\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775341218\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775335500\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491269990\n" }, { "input": "6 2 4\n33189 87907 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491261653\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 245001003", "output": "3093929975\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 19\n5 6 2", "output": "108\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n5 2 3", "output": "19\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 6 11\n5 3 3", "output": "22\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093877764\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "119\n" }, { "input": "1 2 1\n2 4 4\n1 2 1\n7 0 2\n5 3 3", "output": "16\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093863555\n" }, { "input": "3 3 2\n16 17 1\n2 3 5\n2 16 12\n17 7 7\n13 2 3\n12 13 3\n22 15 19\n9 6 2", "output": "109\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3214718680\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n59976 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2872514554\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2929451082\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 74101 245001003", "output": "3093975113\n" }, { "input": "1 2 1\n2 4 6\n0 2 1\n7 6 7\n9 2 3", "output": "23\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 21 12\n17 7 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "124\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n42495 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093879113\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n2 16 12\n17 7 7\n13 2 0\n13 13 3\n22 15 19\n5 6 2", "output": "106\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 796697686\n57317 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093862121\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 327161251\n58589 12598 141577431\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953373873\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n58589 18431 250423809\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 882028374\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2958089934\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 382963164", "output": "2491277056\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 845062869\n60126 62114 382963164", "output": "2491332876\n" }, { "input": "1 2 1\n2 4 7\n3 2 2\n7 6 7\n5 4 3", "output": "20\n" }, { "input": "3 3 2\n16 17 1\n2 7 2\n2 0 12\n17 7 7\n13 2 10\n12 18 3\n16 15 26\n5 6 2", "output": "115\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093966205\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 11501 289910583\n50598 35195 478112689\n13919 1573 103962455\n7953 69657 699253752\n42489 36004 468443709\n2332 42580 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "3093866459\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 218424419\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2593522843\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 91167 245001003", "output": "3094018760\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 289910583\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 135203 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 115476935", "output": "3093921257\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963164", "output": "3093881319\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 796697686\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 37860 845062869\n60126 74101 382963164", "output": "3093880961\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n61732 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669649019\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 15102 382963164", "output": "2775321450\n" }, { "input": "6 2 4\n33189 159130 277349742\n25568 46764 394223083\n8801 53151 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 468443709\n2332 29437 87287886\n18946 19060 715215246\n60126 62114 124089072", "output": "2361485253\n" }, { "input": "3 3 2\n0 17 1\n2 7 5\n2 21 12\n27 2 7\n13 2 3\n12 18 3\n31 15 19\n5 6 2", "output": "134\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093893357\n" }, { "input": "6 2 4\n33189 87907 179450675\n33905 46764 575306520\n8801 53151 327161251\n58589 10425 199827665\n66854 17565 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 1041467256\n42489 98144 468443709\n2332 42580 997425647\n39752 19060 845062869\n60126 74101 382963164", "output": "3459707230\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n58589 7236 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 27851 845062869\n60126 62114 382963164", "output": "2872498383\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 85321 394223083\n8801 53151 3205876\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n74454 98144 496532349\n2332 42580 87287886\n39752 19060 845062869\n60126 62114 570675168", "output": "2611918647\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 118109 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3094048455\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 98144 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093920569\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n58589 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n13919 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n72164 74101 382963164", "output": "3093915140\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183458592\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 13 2\n22 15 22\n9 6 1", "output": "116\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953371846\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 845062869\n60126 62114 382963164", "output": "3669651933\n" }, { "input": "6 2 4\n33189 102169 277349742\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 118670620\n66854 17565 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2775329574\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 107411 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954652970\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8801 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289959\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n110501 17565 289910583\n50598 35195 478112689\n13919 53191 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n105264 135743 245001003", "output": "3093998154\n" }, { "input": "6 2 4\n33189 88609 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093925871\n" }, { "input": "3 3 2\n16 17 1\n2 7 5\n3 12 12\n17 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "112\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 46764 575306520\n8801 53151 327161251\n104581 7236 886275317\n57317 17565 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 65491 845062869\n60126 74101 382963164", "output": "3183448224\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n2 20 12\n17 7 7\n13 2 3\n12 17 2\n22 15 22\n9 6 1", "output": "120\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 46764 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 752437097\n7996 19060 845062869\n60126 62114 382963164", "output": "2953432390\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 500599301\n8801 53151 632227322\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n2332 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3325194212\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954700613\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 394223083\n8490 15308 327161251\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n74454 37174 468443709\n2332 7005 752437097\n39752 19060 845062869\n40358 25029 382963164", "output": "2775289648\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n7953 69657 674703161\n42489 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3069370666\n" }, { "input": "6 2 4\n33189 147435 25397593\n33905 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 136264683\n7953 69657 699253752\n71858 132580 468443709\n2332 27840 752437097\n39752 19060 845062869\n60126 80230 382963164", "output": "3093979395\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n60126 62114 382963164", "output": "2872501090\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n16051 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093917272\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n13919 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512281107\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 168808 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954692606\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 39844 394223083\n9170 53151 327161251\n129926 526 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 2368 134806813\n9712 69657 699253752\n74454 98144 468443709\n2144 42580 752437097\n39752 19060 845062869\n60126 62114 262490364", "output": "2775380931\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 13\n12 18 0\n22 15 2\n6 6 0", "output": "128\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 343885277\n1315 40284 752437097\n39752 19060 845062869\n66232 74101 382963164", "output": "2872499977\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 74934 327161251\n38899 4337 796697686\n66854 17565 289910583\n44701 35195 478112689\n25447 1573 111724159\n9712 69657 699253752\n69352 98144 468443709\n2332 42580 752437097\n21769 19060 845062869\n72164 74101 382963164", "output": "3093926668\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872516096\n" }, { "input": "6 2 4\n33189 148451 277349742\n33905 30594 656167279\n8801 53151 624602328\n58589 12598 214222412\n66854 17565 289910583\n50598 35195 478112689\n26829 1283 103962455\n9712 69657 699253752\n59705 98144 468443709\n2332 42580 1311285814\n7996 19060 845062869\n60126 62114 382963164", "output": "3512294017\n" }, { "input": "6 2 4\n33189 102169 344107733\n33905 46764 394223083\n9873 53151 327161251\n58589 12598 20784962\n66854 34525 173583719\n50598 35195 478112689\n13919 1573 42293659\n17814 69657 699253752\n74454 98144 468443709\n2332 42580 752437097\n39752 19060 1438466979\n60126 62114 382963164", "output": "3368733684\n" }, { "input": "6 2 4\n33189 57442 277349742\n33905 46764 657407748\n6440 53151 213255275\n84495 18431 141577431\n66854 17565 100595605\n50598 56534 499531067\n13919 1573 103962455\n9712 69657 699253752\n74454 266085 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 62114 382963164", "output": "2954789883\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115676655\n" }, { "input": "3 3 2\n29 17 2\n2 7 5\n3 12 12\n21 9 7\n13 2 15\n12 18 0\n22 15 2\n6 6 0", "output": "130\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n13 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "142\n" }, { "input": "6 2 4\n33189 60740 277349742\n33905 29724 575306520\n8801 53151 327161251\n104581 7236 886275317\n68908 15379 289910583\n69438 35195 478112689\n13919 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n63908 65491 845062869\n60126 74101 382963164", "output": "3183459815\n" }, { "input": "3 3 2\n16 17 1\n0 3 5\n0 20 12\n17 7 7\n5 2 2\n12 17 2\n22 15 22\n14 6 1", "output": "117\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n11508 53151 327161251\n58589 1173 78600873\n66854 17565 289910583\n43805 58381 478112689\n9339 1573 103962455\n9712 69657 699253752\n42489 98144 468443709\n2332 36869 752437097\n39752 26806 845062869\n75132 62114 382963164", "output": "2872511516\n" }, { "input": "6 2 4\n33189 87907 402986692\n21176 46764 500599301\n8801 53151 1210998588\n58589 12598 141577431\n66854 17565 130159932\n50598 35195 478112689\n16833 1573 103962455\n9712 69657 699253752\n71970 98144 468443709\n1018 42580 1492635034\n39752 19060 48797902\n60126 62114 382963164", "output": "3903965478\n" }, { "input": "6 2 4\n33189 87907 530443197\n33905 85321 394223083\n8801 27804 4040527\n84495 18431 141577431\n66854 32775 289910583\n50598 35195 478112689\n8201 1573 103962455\n9712 69657 699253752\n119260 98144 496532349\n2332 42580 74611723\n39752 22945 845062869\n60126 62114 570675168", "output": "2645901096\n" }, { "input": "6 2 4\n33189 87907 277349742\n71616 46764 575306520\n12506 53151 261301742\n58589 4337 796697686\n66854 17565 4018814\n5650 35195 478112689\n13919 88414 103962455\n6505 69657 721009150\n42275 135203 468443709\n2332 42580 752437097\n39752 34092 845062869\n60126 21442 115476935", "output": "3115680360\n" }, { "input": "6 2 4\n33189 87907 277349742\n33905 46764 575306520\n8801 53151 45986694\n58589 5487 305429394\n66854 11501 289910583\n50598 35195 478112689\n13919 2504 103962455\n7953 69657 699253752\n42489 36004 275737389\n1315 40284 143834229\n39752 19060 845062869\n66232 74101 382963164", "output": "2598126286\n" }, { "input": "3 3 2\n1 17 1\n2 7 5\n2 21 0\n27 1 7\n23 2 3\n12 26 3\n31 1 19\n5 6 2", "output": "152\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\nnum = list(map(int, input().split()))\n", "n = int(input())\nnum = list(map(int, input().split()))\n\nq = int(input())\n", "n = int(input())\nnum = list(map(int, input().split()))\n\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int, input().split())\n", "n = int(input())\nnum = list(map(int, input().split()))\n\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int, input().split())\n for i in range(e-b):\n num[b+i], num[t+i] = num[t+i], num[b+i]\n", "n = int(input())\nnum = list(map(int, input().split()))\n\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int, input().split())\n for i in range(e-b):\n num[b+i], num[t+i] = num[t+i], num[b+i]\n\nprint(' '.join(str(n) for n in num))\n" ]
7
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n=int(input())\n", "n=int(input())\na=list(map(int, input().split()))\n", "n=int(input())\na=list(map(int, input().split()))\nq=int(input())\n", "n=int(input())\na=list(map(int, input().split()))\nq=int(input())\n\nfor i in range(q):\n b,e,t=map(int, input().split())\n", "n=int(input())\na=list(map(int, input().split()))\nq=int(input())\n\nfor i in range(q):\n b,e,t=map(int, input().split())\n if t>b:\n a=a[:b]+a[t:t+e-b]+a[e:t]+a[b:e]+a[t+e-b:]\n", "n=int(input())\na=list(map(int, input().split()))\nq=int(input())\n\nfor i in range(q):\n b,e,t=map(int, input().split())\n if t>b:\n a=a[:b]+a[t:t+e-b]+a[e:t]+a[b:e]+a[t+e-b:]\n else:\n a=a[:t]+a[b:e]+a[t+e-b:b]+a[t:t+e-b]+a[e:]\n", "n=int(input())\na=list(map(int, input().split()))\nq=int(input())\n\nfor i in range(q):\n b,e,t=map(int, input().split())\n if t>b:\n a=a[:b]+a[t:t+e-b]+a[e:t]+a[b:e]+a[t+e-b:]\n else:\n a=a[:t]+a[b:e]+a[t+e-b:b]+a[t:t+e-b]+a[e:]\nprint(*a)\n" ]
8
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "def resolve():\n from collections import deque\n", "def resolve():\n from collections import deque\n N = int(input())\n", "def resolve():\n from collections import deque\n N = int(input())\n A = [int(i) for i in input().split()]\n", "def resolve():\n from collections import deque\n N = int(input())\n A = [int(i) for i in input().split()]\n Q = int(input())\n", "def resolve():\n from collections import deque\n N = int(input())\n A = [int(i) for i in input().split()]\n Q = int(input())\n ans = [i for i in range(N)]\n", "def resolve():\n from collections import deque\n N = int(input())\n A = [int(i) for i in input().split()]\n Q = int(input())\n ans = [i for i in range(N)]\n for _ in range(Q):\n b, e, t = [int(i) for i in input().split()]\n", "def resolve():\n from collections import deque\n N = int(input())\n A = [int(i) for i in input().split()]\n Q = int(input())\n ans = [i for i in range(N)]\n for _ in range(Q):\n b, e, t = [int(i) for i in input().split()]\n tmp = deque(ans[t:t + (e - b)])\n", "def resolve():\n from collections import deque\n N = int(input())\n A = [int(i) for i in input().split()]\n Q = int(input())\n ans = [i for i in range(N)]\n for _ in range(Q):\n b, e, t = [int(i) for i in input().split()]\n tmp = deque(ans[t:t + (e - b)])\n for i in range(b, e):\n ans[i + t - b] = ans[i]\n", "def resolve():\n from collections import deque\n N = int(input())\n A = [int(i) for i in input().split()]\n Q = int(input())\n ans = [i for i in range(N)]\n for _ in range(Q):\n b, e, t = [int(i) for i in input().split()]\n tmp = deque(ans[t:t + (e - b)])\n for i in range(b, e):\n ans[i + t - b] = ans[i]\n ans[i] = tmp[i - b]\n", "def resolve():\n from collections import deque\n N = int(input())\n A = [int(i) for i in input().split()]\n Q = int(input())\n ans = [i for i in range(N)]\n for _ in range(Q):\n b, e, t = [int(i) for i in input().split()]\n tmp = deque(ans[t:t + (e - b)])\n for i in range(b, e):\n ans[i + t - b] = ans[i]\n ans[i] = tmp[i - b]\n prt = [0] * N\n", "def resolve():\n from collections import deque\n N = int(input())\n A = [int(i) for i in input().split()]\n Q = int(input())\n ans = [i for i in range(N)]\n for _ in range(Q):\n b, e, t = [int(i) for i in input().split()]\n tmp = deque(ans[t:t + (e - b)])\n for i in range(b, e):\n ans[i + t - b] = ans[i]\n ans[i] = tmp[i - b]\n prt = [0] * N\n for i in range(N):\n prt[i] = A[ans[i]]\n", "def resolve():\n from collections import deque\n N = int(input())\n A = [int(i) for i in input().split()]\n Q = int(input())\n ans = [i for i in range(N)]\n for _ in range(Q):\n b, e, t = [int(i) for i in input().split()]\n tmp = deque(ans[t:t + (e - b)])\n for i in range(b, e):\n ans[i + t - b] = ans[i]\n ans[i] = tmp[i - b]\n prt = [0] * N\n for i in range(N):\n prt[i] = A[ans[i]]\n print(*prt)\n", "def resolve():\n from collections import deque\n N = int(input())\n A = [int(i) for i in input().split()]\n Q = int(input())\n ans = [i for i in range(N)]\n for _ in range(Q):\n b, e, t = [int(i) for i in input().split()]\n tmp = deque(ans[t:t + (e - b)])\n for i in range(b, e):\n ans[i + t - b] = ans[i]\n ans[i] = tmp[i - b]\n prt = [0] * N\n for i in range(N):\n prt[i] = A[ans[i]]\n print(*prt)\n\n\nresolve()\n" ]
14
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\nbox = list(map(int, input().split()))\n", "n = int(input())\nbox = list(map(int, input().split()))\nq = int(input())\n", "n = int(input())\nbox = list(map(int, input().split()))\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int, input().split())\n", "n = int(input())\nbox = list(map(int, input().split()))\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int, input().split())\n for k in range(e-b):\n box[t+k],box[b+k] = box[b+k],box[t+k]\n", "n = int(input())\nbox = list(map(int, input().split()))\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int, input().split())\n for k in range(e-b):\n box[t+k],box[b+k] = box[b+k],box[t+k]\n\nprint(*box)\n" ]
7
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "def my_swap(ary, b, e, t):\n k = 0\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n \n \n k += 1\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n temp = ary[b+k]\n \n \n k += 1\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n temp = ary[b+k]\n ary[b+k] = ary[t+k]\n \n k += 1\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n temp = ary[b+k]\n ary[b+k] = ary[t+k]\n ary[t+k] = temp\n k += 1\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n temp = ary[b+k]\n ary[b+k] = ary[t+k]\n ary[t+k] = temp\n k += 1\n return ary\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n temp = ary[b+k]\n ary[b+k] = ary[t+k]\n ary[t+k] = temp\n k += 1\n return ary\n\n\ndef main():\n input()\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n temp = ary[b+k]\n ary[b+k] = ary[t+k]\n ary[t+k] = temp\n k += 1\n return ary\n\n\ndef main():\n input()\n ary = [int(x) for x in input().split(' ')]\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n temp = ary[b+k]\n ary[b+k] = ary[t+k]\n ary[t+k] = temp\n k += 1\n return ary\n\n\ndef main():\n input()\n ary = [int(x) for x in input().split(' ')]\n q = int(input())\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n temp = ary[b+k]\n ary[b+k] = ary[t+k]\n ary[t+k] = temp\n k += 1\n return ary\n\n\ndef main():\n input()\n ary = [int(x) for x in input().split(' ')]\n q = int(input())\n for i in range(q):\n b, e, t = [int(x) for x in input().split(' ')]\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n temp = ary[b+k]\n ary[b+k] = ary[t+k]\n ary[t+k] = temp\n k += 1\n return ary\n\n\ndef main():\n input()\n ary = [int(x) for x in input().split(' ')]\n q = int(input())\n for i in range(q):\n b, e, t = [int(x) for x in input().split(' ')]\n ary = my_swap(ary, b, e, t)\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n temp = ary[b+k]\n ary[b+k] = ary[t+k]\n ary[t+k] = temp\n k += 1\n return ary\n\n\ndef main():\n input()\n ary = [int(x) for x in input().split(' ')]\n q = int(input())\n for i in range(q):\n b, e, t = [int(x) for x in input().split(' ')]\n ary = my_swap(ary, b, e, t)\n print(' '.join([str(x) for x in ary]))\n", "def my_swap(ary, b, e, t):\n k = 0\n while k < (e - b):\n temp = ary[b+k]\n ary[b+k] = ary[t+k]\n ary[t+k] = temp\n k += 1\n return ary\n\n\ndef main():\n input()\n ary = [int(x) for x in input().split(' ')]\n q = int(input())\n for i in range(q):\n b, e, t = [int(x) for x in input().split(' ')]\n ary = my_swap(ary, b, e, t)\n print(' '.join([str(x) for x in ary]))\n\n\nif __name__ == '__main__':\n main()\n" ]
14
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\na = list(map(int, input().split()))\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = list(map(int, input().split()))\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = list(map(int, input().split()))\n for k in range(e-b):\n a[b+k], a[t+k] = a[t+k], a[b+k]\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = list(map(int, input().split()))\n for k in range(e-b):\n a[b+k], a[t+k] = a[t+k], a[b+k]\nprint(\" \".join(map(str, a)))\n" ]
7
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "# -*- coding: utf-8 -*-\n", "# -*- coding: utf-8 -*-\n\"\"\"\nBasic Modifications - Swap\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n\n\"\"\"\n", "# -*- coding: utf-8 -*-\n\"\"\"\nBasic Modifications - Swap\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n\n\"\"\"\n_ = input()\n", "# -*- coding: utf-8 -*-\n\"\"\"\nBasic Modifications - Swap\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n\n\"\"\"\n_ = input()\nA = list(input().split())\n", "# -*- coding: utf-8 -*-\n\"\"\"\nBasic Modifications - Swap\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n\n\"\"\"\n_ = input()\nA = list(input().split())\nfor _ in range(int(input())):\n b, e, t = map(int, input().split())\n", "# -*- coding: utf-8 -*-\n\"\"\"\nBasic Modifications - Swap\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n\n\"\"\"\n_ = input()\nA = list(input().split())\nfor _ in range(int(input())):\n b, e, t = map(int, input().split())\n for k in range(e-b):\n A[b+k], A[t+k] = A[t+k], A[b+k]\n", "# -*- coding: utf-8 -*-\n\"\"\"\nBasic Modifications - Swap\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n\n\"\"\"\n_ = input()\nA = list(input().split())\nfor _ in range(int(input())):\n b, e, t = map(int, input().split())\n for k in range(e-b):\n A[b+k], A[t+k] = A[t+k], A[b+k]\nprint(*A, sep=' ')\n" ]
8
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "input()\n", "input()\n*a,=map(int,input().split())\n", "input()\n*a,=map(int,input().split())\nfor i in range(int(input())):\n l,r,t=map(int,input().split())\n", "input()\n*a,=map(int,input().split())\nfor i in range(int(input())):\n l,r,t=map(int,input().split())\n a[l:r],a[t:t+r-l]=a[t:t+r-l],a[l:r]\n", "input()\n*a,=map(int,input().split())\nfor i in range(int(input())):\n l,r,t=map(int,input().split())\n a[l:r],a[t:t+r-l]=a[t:t+r-l],a[l:r]\nprint(*a)\n" ]
6
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\nA = list(map(int, input().split()))\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\nfor i in range(q):\n b, e, t = list(map(int, input().split()))\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\nfor i in range(q):\n b, e, t = list(map(int, input().split()))\n\n for j in range(e - b):\n A[b + j], A[t + j] = A[t + j], A[b + j]\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\nfor i in range(q):\n b, e, t = list(map(int, input().split()))\n\n for j in range(e - b):\n A[b + j], A[t + j] = A[t + j], A[b + j]\n\nprint(*A)\n" ]
7
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "# AOJ ITP2_4_C: Swap\n# Python3 2018.6.24 bal4u\n", "# AOJ ITP2_4_C: Swap\n# Python3 2018.6.24 bal4u\n\nn = int(input())\n", "# AOJ ITP2_4_C: Swap\n# Python3 2018.6.24 bal4u\n\nn = int(input())\na = list(map(int, input().split()))\n", "# AOJ ITP2_4_C: Swap\n# Python3 2018.6.24 bal4u\n\nn = int(input())\na = list(map(int, input().split()))\nq = int(input())\n", "# AOJ ITP2_4_C: Swap\n# Python3 2018.6.24 bal4u\n\nn = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n", "# AOJ ITP2_4_C: Swap\n# Python3 2018.6.24 bal4u\n\nn = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n s = t+e-b\n", "# AOJ ITP2_4_C: Swap\n# Python3 2018.6.24 bal4u\n\nn = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n s = t+e-b\n if t > b:\n a = a[:b] + a[t:s] + a[e:t] + a[b:e] + a[s:]\n", "# AOJ ITP2_4_C: Swap\n# Python3 2018.6.24 bal4u\n\nn = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n s = t+e-b\n if t > b:\n a = a[:b] + a[t:s] + a[e:t] + a[b:e] + a[s:]\n else:\n a = a[:t] + a[b:e] + a[s:b] + a[t:s] + a[e:]\n", "# AOJ ITP2_4_C: Swap\n# Python3 2018.6.24 bal4u\n\nn = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n s = t+e-b\n if t > b:\n a = a[:b] + a[t:s] + a[e:t] + a[b:e] + a[s:]\n else:\n a = a[:t] + a[b:e] + a[s:b] + a[t:s] + a[e:]\nprint(*a)\n" ]
10
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "N = int(input())\n", "N = int(input())\nA = list(map(int,input().split()))\n", "N = int(input())\nA = list(map(int,input().split()))\n\nQ = int(input())\n", "N = int(input())\nA = list(map(int,input().split()))\n\nQ = int(input())\nfor _ in range(Q):\n b,e,t = map(int,input().split())\n", "N = int(input())\nA = list(map(int,input().split()))\n\nQ = int(input())\nfor _ in range(Q):\n b,e,t = map(int,input().split())\n for k in range(e-b):\n A[b+k],A[t+k] = A[t+k],A[b+k]\n", "N = int(input())\nA = list(map(int,input().split()))\n\nQ = int(input())\nfor _ in range(Q):\n b,e,t = map(int,input().split())\n for k in range(e-b):\n A[b+k],A[t+k] = A[t+k],A[b+k]\n\nprint(*A)\n" ]
7
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\nA = list(map(int, input().split()))\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\nfor i in range(q):\n queryi = list(map(int, input().split()))\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\nfor i in range(q):\n queryi = list(map(int, input().split()))\n b = queryi[0]\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\nfor i in range(q):\n queryi = list(map(int, input().split()))\n b = queryi[0]\n e = queryi[1]\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\nfor i in range(q):\n queryi = list(map(int, input().split()))\n b = queryi[0]\n e = queryi[1]\n t = queryi[2]\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\nfor i in range(q):\n queryi = list(map(int, input().split()))\n b = queryi[0]\n e = queryi[1]\n t = queryi[2]\n\n for i in range(e-b):\n temp = A[b+i]\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\nfor i in range(q):\n queryi = list(map(int, input().split()))\n b = queryi[0]\n e = queryi[1]\n t = queryi[2]\n\n for i in range(e-b):\n temp = A[b+i]\n A[b+i] = A[t+i]\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\nfor i in range(q):\n queryi = list(map(int, input().split()))\n b = queryi[0]\n e = queryi[1]\n t = queryi[2]\n\n for i in range(e-b):\n temp = A[b+i]\n A[b+i] = A[t+i]\n A[t+i] = temp\n", "n = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\nfor i in range(q):\n queryi = list(map(int, input().split()))\n b = queryi[0]\n e = queryi[1]\n t = queryi[2]\n\n for i in range(e-b):\n temp = A[b+i]\n A[b+i] = A[t+i]\n A[t+i] = temp\n\nprint(*A)\n" ]
12
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\na = list(map(int, input().split()))\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor _ in range(q):\n b,e,t = map(int, input().split())\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor _ in range(q):\n b,e,t = map(int, input().split())\n x = a[t:t+e-b]\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor _ in range(q):\n b,e,t = map(int, input().split())\n x = a[t:t+e-b]\n a[t:t+e-b] = a[b:e]\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor _ in range(q):\n b,e,t = map(int, input().split())\n x = a[t:t+e-b]\n a[t:t+e-b] = a[b:e]\n a[b:e] = x\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor _ in range(q):\n b,e,t = map(int, input().split())\n x = a[t:t+e-b]\n a[t:t+e-b] = a[b:e]\n a[b:e] = x\nprint(\" \".join(map(str,a)))\n" ]
9
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "from sys import stdin\n", "from sys import stdin\n\nn = int(stdin.readline())\n", "from sys import stdin\n\nn = int(stdin.readline())\nl = list(stdin.readline().split())\n", "from sys import stdin\n\nn = int(stdin.readline())\nl = list(stdin.readline().split())\nq = int(stdin.readline())\n", "from sys import stdin\n\nn = int(stdin.readline())\nl = list(stdin.readline().split())\nq = int(stdin.readline())\n\nfor i in range(q):\n inp_l = list(map(int,stdin.readline().split()))\n", "from sys import stdin\n\nn = int(stdin.readline())\nl = list(stdin.readline().split())\nq = int(stdin.readline())\n\nfor i in range(q):\n inp_l = list(map(int,stdin.readline().split()))\n displacement = inp_l[1] - inp_l[0]\n", "from sys import stdin\n\nn = int(stdin.readline())\nl = list(stdin.readline().split())\nq = int(stdin.readline())\n\nfor i in range(q):\n inp_l = list(map(int,stdin.readline().split()))\n displacement = inp_l[1] - inp_l[0]\n for i in range(displacement):\n l[inp_l[0] + i],l[inp_l[2] + i] =l[inp_l[2] + i],l[inp_l[0] + i]\n", "from sys import stdin\n\nn = int(stdin.readline())\nl = list(stdin.readline().split())\nq = int(stdin.readline())\n\nfor i in range(q):\n inp_l = list(map(int,stdin.readline().split()))\n displacement = inp_l[1] - inp_l[0]\n for i in range(displacement):\n l[inp_l[0] + i],l[inp_l[2] + i] =l[inp_l[2] + i],l[inp_l[0] + i]\n\nprint(' '.join(l))\n", "\nfrom sys import stdin\n\nn = int(stdin.readline())\nl = list(stdin.readline().split())\nq = int(stdin.readline())\n\nfor i in range(q):\n inp_l = list(map(int,stdin.readline().split()))\n displacement = inp_l[1] - inp_l[0]\n for i in range(displacement):\n l[inp_l[0] + i],l[inp_l[2] + i] =l[inp_l[2] + i],l[inp_l[0] + i]\n\nprint(' '.join(l))\n" ]
10
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "def swaping(list2,q,b,e,t):\n\n k = e - b\n", "def swaping(list2,q,b,e,t):\n\n k = e - b\n\n for i in range(k):\n list2[b+i],list2[t+i] = list2[t+i],list2[b+i]\n", "def swaping(list2,q,b,e,t):\n\n k = e - b\n\n for i in range(k):\n list2[b+i],list2[t+i] = list2[t+i],list2[b+i]\n\n\nif __name__ == '__main__':\n\n num = int(input())\n", "def swaping(list2,q,b,e,t):\n\n k = e - b\n\n for i in range(k):\n list2[b+i],list2[t+i] = list2[t+i],list2[b+i]\n\n\nif __name__ == '__main__':\n\n num = int(input())\n list2 = input().split()\n", "def swaping(list2,q,b,e,t):\n\n k = e - b\n\n for i in range(k):\n list2[b+i],list2[t+i] = list2[t+i],list2[b+i]\n\n\nif __name__ == '__main__':\n\n num = int(input())\n list2 = input().split()\n q = int(input())\n", "def swaping(list2,q,b,e,t):\n\n k = e - b\n\n for i in range(k):\n list2[b+i],list2[t+i] = list2[t+i],list2[b+i]\n\n\nif __name__ == '__main__':\n\n num = int(input())\n list2 = input().split()\n q = int(input())\n\n for i in range(q):\n b,e,t = map(int,input().split())\n", "def swaping(list2,q,b,e,t):\n\n k = e - b\n\n for i in range(k):\n list2[b+i],list2[t+i] = list2[t+i],list2[b+i]\n\n\nif __name__ == '__main__':\n\n num = int(input())\n list2 = input().split()\n q = int(input())\n\n for i in range(q):\n b,e,t = map(int,input().split())\n\n swaping(list2,q,b,e,t)\n", "def swaping(list2,q,b,e,t):\n\n k = e - b\n\n for i in range(k):\n list2[b+i],list2[t+i] = list2[t+i],list2[b+i]\n\n\nif __name__ == '__main__':\n\n num = int(input())\n list2 = input().split()\n q = int(input())\n\n for i in range(q):\n b,e,t = map(int,input().split())\n\n swaping(list2,q,b,e,t)\n\n print(\" \".join(list2))\n" ]
9
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\na = list(map(int, input().split(' ')))\n", "n = int(input())\na = list(map(int, input().split(' ')))\nq = int(input())\n", "n = int(input())\na = list(map(int, input().split(' ')))\nq = int(input())\nfor i in range(q):\n b, e, t = list(map(int, input().split(' ')))\n", "n = int(input())\na = list(map(int, input().split(' ')))\nq = int(input())\nfor i in range(q):\n b, e, t = list(map(int, input().split(' ')))\n for k in range(e-b):\n a[b+k], a[t+k] = a[t+k], a[b+k]\n", "n = int(input())\na = list(map(int, input().split(' ')))\nq = int(input())\nfor i in range(q):\n b, e, t = list(map(int, input().split(' ')))\n for k in range(e-b):\n a[b+k], a[t+k] = a[t+k], a[b+k]\nprint(' '.join(list(map(str, a))))\n" ]
7
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "# OUTPUT\n", "n = int(input())\n\n\n# OUTPUT\n", "n = int(input())\n\nA = list(map(int, input().split()))\n\n\n# OUTPUT\n", "n = int(input())\n\nA = list(map(int, input().split()))\n\nq = int(input())\n\n\n# OUTPUT\n", "n = int(input())\n\nA = list(map(int, input().split()))\n\nq = int(input())\n\n\nfor _ in range(q):\n\n b, e, t = map(int, input().split())\n\n \n# OUTPUT\n", "n = int(input())\n\nA = list(map(int, input().split()))\n\nq = int(input())\n\n\nfor _ in range(q):\n\n b, e, t = map(int, input().split())\n\n for k in range(e - b):\n\n A[b + k], A[t + k] = A[t + k], A[b + k]\n\n\n# OUTPUT\n", "n = int(input())\n\nA = list(map(int, input().split()))\n\nq = int(input())\n\n\nfor _ in range(q):\n\n b, e, t = map(int, input().split())\n\n for k in range(e - b):\n\n A[b + k], A[t + k] = A[t + k], A[b + k]\n\n\n# OUTPUT\nprint(*A)\n" ]
8
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "print()\n", "n = int(input())\n\n\nprint()\n", "n = int(input())\na = list(map(int,input().split()))\n\n\nprint()\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\n\n\nprint()\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor j in range(q):\n b, e, t = map(int,input().split())\n \n\nprint()\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor j in range(q):\n b, e, t = map(int,input().split())\n for k in range(e - b):\n aa = a[b+k]\n \n \nprint()\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor j in range(q):\n b, e, t = map(int,input().split())\n for k in range(e - b):\n aa = a[b+k]\n a[b+k] = a[t+k]\n \n\nprint()\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor j in range(q):\n b, e, t = map(int,input().split())\n for k in range(e - b):\n aa = a[b+k]\n a[b+k] = a[t+k]\n a[t+k] = aa\n\n\nprint()\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor j in range(q):\n b, e, t = map(int,input().split())\n for k in range(e - b):\n aa = a[b+k]\n a[b+k] = a[t+k]\n a[t+k] = aa\n\nprint(a[0],end=\"\")\n\nprint()\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor j in range(q):\n b, e, t = map(int,input().split())\n for k in range(e - b):\n aa = a[b+k]\n a[b+k] = a[t+k]\n a[t+k] = aa\n\nprint(a[0],end=\"\")\nfor aa in a[1:]:\n print(\" {}\".format(aa),end=\"\")\nprint()\n" ]
11
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\na = list(map(int, input().split()))\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int, input().split())\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int, input().split())\n for k in range(e-b):\n a[t+k],a[b+k] = a[b+k],a[t+k]\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int, input().split())\n for k in range(e-b):\n a[t+k],a[b+k] = a[b+k],a[t+k]\n\nprint(*a)\n" ]
7
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n# Swap\n", "# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n# Swap\n\nfrom collections import deque\n", "# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n# Swap\n\nfrom collections import deque\nimport sys\n", "# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n# Swap\n\nfrom collections import deque\nimport sys\ninput = sys.stdin.readline\n", "# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n# Swap\n\nfrom collections import deque\nimport sys\ninput = sys.stdin.readline\n\ndef main():\n n1 = int(input())\n", "# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n# Swap\n\nfrom collections import deque\nimport sys\ninput = sys.stdin.readline\n\ndef main():\n n1 = int(input())\n l1 = list(map(int,input().split()))\n", "# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n# Swap\n\nfrom collections import deque\nimport sys\ninput = sys.stdin.readline\n\ndef main():\n n1 = int(input())\n l1 = list(map(int,input().split()))\n for i in range(int(input())):\n (b,e,t) = map(int,input().split())\n", "# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n# Swap\n\nfrom collections import deque\nimport sys\ninput = sys.stdin.readline\n\ndef main():\n n1 = int(input())\n l1 = list(map(int,input().split()))\n for i in range(int(input())):\n (b,e,t) = map(int,input().split())\n for k in range(e-b):\n l1[k+b],l1[t+k] = l1[t+k] ,l1[k+b]\n", "# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n# Swap\n\nfrom collections import deque\nimport sys\ninput = sys.stdin.readline\n\ndef main():\n n1 = int(input())\n l1 = list(map(int,input().split()))\n for i in range(int(input())):\n (b,e,t) = map(int,input().split())\n for k in range(e-b):\n l1[k+b],l1[t+k] = l1[t+k] ,l1[k+b]\n print (\" \".join(map(str,l1)))\n", "# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_4_C&lang=jp\n# Swap\n\nfrom collections import deque\nimport sys\ninput = sys.stdin.readline\n\ndef main():\n n1 = int(input())\n l1 = list(map(int,input().split()))\n for i in range(int(input())):\n (b,e,t) = map(int,input().split())\n for k in range(e-b):\n l1[k+b],l1[t+k] = l1[t+k] ,l1[k+b]\n print (\" \".join(map(str,l1)))\n\nif __name__ == '__main__':\n main()\n" ]
11
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\na = list(map(int, input().split()))\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n s = t+e-b\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n s = t+e-b\n if t > b:\n a = a[:b] + a[t:s] + a[e:t] + a[b:e] + a[s:]\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n s = t+e-b\n if t > b:\n a = a[:b] + a[t:s] + a[e:t] + a[b:e] + a[s:]\n else:\n a = a[:t] + a[b:e] + a[s:b] + a[t:s] + a[e:]\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n s = t+e-b\n if t > b:\n a = a[:b] + a[t:s] + a[e:t] + a[b:e] + a[s:]\n else:\n a = a[:t] + a[b:e] + a[s:b] + a[t:s] + a[e:]\nprint(*a)\n" ]
9
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n=input()\n", "n=input()\nl=list(map(int,input().split()))\n", "n=input()\nl=list(map(int,input().split()))\nn=int(input())\n", "n=input()\nl=list(map(int,input().split()))\nn=int(input())\nfor i in range(n):\n b,e,t=map(int,input().split())\n", "n=input()\nl=list(map(int,input().split()))\nn=int(input())\nfor i in range(n):\n b,e,t=map(int,input().split())\n l1=l[b:e]\n", "n=input()\nl=list(map(int,input().split()))\nn=int(input())\nfor i in range(n):\n b,e,t=map(int,input().split())\n l1=l[b:e]\n l2=l[t:t+e-b]\n", "n=input()\nl=list(map(int,input().split()))\nn=int(input())\nfor i in range(n):\n b,e,t=map(int,input().split())\n l1=l[b:e]\n l2=l[t:t+e-b]\n l[b:e]=l2\n", "n=input()\nl=list(map(int,input().split()))\nn=int(input())\nfor i in range(n):\n b,e,t=map(int,input().split())\n l1=l[b:e]\n l2=l[t:t+e-b]\n l[b:e]=l2\n l[t:t+e-b]=l1\n", "n=input()\nl=list(map(int,input().split()))\nn=int(input())\nfor i in range(n):\n b,e,t=map(int,input().split())\n l1=l[b:e]\n l2=l[t:t+e-b]\n l[b:e]=l2\n l[t:t+e-b]=l1\n\nl3=map(str,l)\n", "n=input()\nl=list(map(int,input().split()))\nn=int(input())\nfor i in range(n):\n b,e,t=map(int,input().split())\n l1=l[b:e]\n l2=l[t:t+e-b]\n l[b:e]=l2\n l[t:t+e-b]=l1\n\nl3=map(str,l)\nprint(' '.join(map(str,l3)))\n" ]
11
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "def main():\n n = int(input())\n \n \nmain()\n", "def main():\n n = int(input())\n seq = [int(a) for a in input().split()]\n \n\nmain()\n", "def main():\n n = int(input())\n seq = [int(a) for a in input().split()]\n q = int(input())\n\n \nmain()\n", "def main():\n n = int(input())\n seq = [int(a) for a in input().split()]\n q = int(input())\n\n for _ in range(q):\n b, e, t = map(int, input().split())\n \n \nmain()\n", "def main():\n n = int(input())\n seq = [int(a) for a in input().split()]\n q = int(input())\n\n for _ in range(q):\n b, e, t = map(int, input().split())\n for k in range(e-b):\n tmp = seq[t+k]\n \n \nmain()\n", "def main():\n n = int(input())\n seq = [int(a) for a in input().split()]\n q = int(input())\n\n for _ in range(q):\n b, e, t = map(int, input().split())\n for k in range(e-b):\n tmp = seq[t+k]\n seq[t+k] = seq[b+k]\n \n \nmain()\n", "def main():\n n = int(input())\n seq = [int(a) for a in input().split()]\n q = int(input())\n\n for _ in range(q):\n b, e, t = map(int, input().split())\n for k in range(e-b):\n tmp = seq[t+k]\n seq[t+k] = seq[b+k]\n seq[b+k] = tmp\n \n\nmain()\n", "def main():\n n = int(input())\n seq = [int(a) for a in input().split()]\n q = int(input())\n\n for _ in range(q):\n b, e, t = map(int, input().split())\n for k in range(e-b):\n tmp = seq[t+k]\n seq[t+k] = seq[b+k]\n seq[b+k] = tmp\n print(*seq)\n\nmain()\n" ]
9
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = input()\n", "n = input()\nA = list(input().split())\n", "n = input()\nA = list(input().split())\nfor i in range(int(input())):\n b, e, t = map(int, input().split())\n", "n = input()\nA = list(input().split())\nfor i in range(int(input())):\n b, e, t = map(int, input().split())\n for k in range(e - b):\n A[b+k], A[t+k] = A[t+k], A[b+k]\n", "n = input()\nA = list(input().split())\nfor i in range(int(input())):\n b, e, t = map(int, input().split())\n for k in range(e - b):\n A[b+k], A[t+k] = A[t+k], A[b+k]\n\nprint(*A, sep=' ')\n" ]
6
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\na = list(map(int,input().split()))\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor i in range(q):\n b,e,t = map(int,input().split())\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor i in range(q):\n b,e,t = map(int,input().split())\n for k in range(e-b):\n a[b+k],a[t+k] = a[t+k],a[b+k]\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor i in range(q):\n b,e,t = map(int,input().split())\n for k in range(e-b):\n a[b+k],a[t+k] = a[t+k],a[b+k]\nprint(*a)\n" ]
7
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\nL = [int(x) for x in input().split()]\n", "n = int(input())\nL = [int(x) for x in input().split()]\nn = int(input())\n", "n = int(input())\nL = [int(x) for x in input().split()]\nn = int(input())\nfor _ in range(n):\n b, e, t = [int(x) for x in input().split()]\n", "n = int(input())\nL = [int(x) for x in input().split()]\nn = int(input())\nfor _ in range(n):\n b, e, t = [int(x) for x in input().split()]\n L[b:e], L[t:t+e-b] = L[t:t+e-b], L[b:e]\n", "n = int(input())\nL = [int(x) for x in input().split()]\nn = int(input())\nfor _ in range(n):\n b, e, t = [int(x) for x in input().split()]\n L[b:e], L[t:t+e-b] = L[t:t+e-b], L[b:e]\nprint(*L)\n" ]
7
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\na = list(map(int,input().split()))\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int,input().split())\n # tmp = a[:]\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int,input().split())\n # tmp = a[:]\n for k in range(e-b):\n # a[b+k] = tmp[t+k]\n # a[t+k] = tmp[b+k]\n a[b+k], a[t+k] = a[t+k], a[b+k]\n", "n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nfor _ in range(q):\n b, e, t = map(int,input().split())\n # tmp = a[:]\n for k in range(e-b):\n # a[b+k] = tmp[t+k]\n # a[t+k] = tmp[b+k]\n a[b+k], a[t+k] = a[t+k], a[b+k]\n\nprint(*a)\n" ]
7
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\na = list(map(int, input().split()))\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n if b < t:\n a = a[:b] + a[t:t+e-b] + a[e:t] + a[b:e] + a[t+e-b:]\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n if b < t:\n a = a[:b] + a[t:t+e-b] + a[e:t] + a[b:e] + a[t+e-b:]\n else:\n a = a[:t] + a[b:e] + a[t+e-b:b] + a[t:t+e-b] + a[e:]\n", "n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nfor i in range(q):\n b, e, t = map(int, input().split())\n if b < t:\n a = a[:b] + a[t:t+e-b] + a[e:t] + a[b:e] + a[t+e-b:]\n else:\n a = a[:t] + a[b:e] + a[t+e-b:b] + a[t:t+e-b] + a[e:]\nprint(*a)\n" ]
8
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "def swapRange(A,b,e,t):\n \n return A\n", "def swapRange(A,b,e,t):\n for k in range(e-b):\n A[b+k],A[t+k]=A[t+k],A[b+k]\n return A\n", "def swapRange(A,b,e,t):\n for k in range(e-b):\n A[b+k],A[t+k]=A[t+k],A[b+k]\n return A\n\nn=int(input())\n", "def swapRange(A,b,e,t):\n for k in range(e-b):\n A[b+k],A[t+k]=A[t+k],A[b+k]\n return A\n\nn=int(input())\nA=list(map(int,input().split()))\n", "def swapRange(A,b,e,t):\n for k in range(e-b):\n A[b+k],A[t+k]=A[t+k],A[b+k]\n return A\n\nn=int(input())\nA=list(map(int,input().split()))\nq=int(input())\n", "def swapRange(A,b,e,t):\n for k in range(e-b):\n A[b+k],A[t+k]=A[t+k],A[b+k]\n return A\n\nn=int(input())\nA=list(map(int,input().split()))\nq=int(input())\n\nfor i in range(q):\n query=list(map(int,input().split()))\n", "def swapRange(A,b,e,t):\n for k in range(e-b):\n A[b+k],A[t+k]=A[t+k],A[b+k]\n return A\n\nn=int(input())\nA=list(map(int,input().split()))\nq=int(input())\n\nfor i in range(q):\n query=list(map(int,input().split()))\n A=swapRange(A,query[0],query[1],query[2])\n", "def swapRange(A,b,e,t):\n for k in range(e-b):\n A[b+k],A[t+k]=A[t+k],A[b+k]\n return A\n\nn=int(input())\nA=list(map(int,input().split()))\nq=int(input())\n\nfor i in range(q):\n query=list(map(int,input().split()))\n A=swapRange(A,query[0],query[1],query[2])\nprint(' '.join(map(str,A)))\n" ]
9
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "def swap_range(li, b, e, t):\n \"\"\"Swap element (b + k) and element (t + k) (0 <= k < e-b).\n\n >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']\n >>> swap_range(li, 1, 3, 5)\n >>> \" \".join(li)\n '1 6 7 4 5 2 3 8'\n >>> swap_range(li, 3, 5, 4)\n >>> \" \".join(li)\n '1 6 7 5 2 4 3 8'\n \"\"\"\n", "def swap_range(li, b, e, t):\n \"\"\"Swap element (b + k) and element (t + k) (0 <= k < e-b).\n\n >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']\n >>> swap_range(li, 1, 3, 5)\n >>> \" \".join(li)\n '1 6 7 4 5 2 3 8'\n >>> swap_range(li, 3, 5, 4)\n >>> \" \".join(li)\n '1 6 7 5 2 4 3 8'\n \"\"\"\n for k in range(e-b):\n li[b+k], li[t+k] = li[t+k], li[b+k]\n", "def swap_range(li, b, e, t):\n \"\"\"Swap element (b + k) and element (t + k) (0 <= k < e-b).\n\n >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']\n >>> swap_range(li, 1, 3, 5)\n >>> \" \".join(li)\n '1 6 7 4 5 2 3 8'\n >>> swap_range(li, 3, 5, 4)\n >>> \" \".join(li)\n '1 6 7 5 2 4 3 8'\n \"\"\"\n for k in range(e-b):\n li[b+k], li[t+k] = li[t+k], li[b+k]\n\n\ndef run():\n n = int(input())\n", "def swap_range(li, b, e, t):\n \"\"\"Swap element (b + k) and element (t + k) (0 <= k < e-b).\n\n >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']\n >>> swap_range(li, 1, 3, 5)\n >>> \" \".join(li)\n '1 6 7 4 5 2 3 8'\n >>> swap_range(li, 3, 5, 4)\n >>> \" \".join(li)\n '1 6 7 5 2 4 3 8'\n \"\"\"\n for k in range(e-b):\n li[b+k], li[t+k] = li[t+k], li[b+k]\n\n\ndef run():\n n = int(input())\n li = input().split()\n", "def swap_range(li, b, e, t):\n \"\"\"Swap element (b + k) and element (t + k) (0 <= k < e-b).\n\n >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']\n >>> swap_range(li, 1, 3, 5)\n >>> \" \".join(li)\n '1 6 7 4 5 2 3 8'\n >>> swap_range(li, 3, 5, 4)\n >>> \" \".join(li)\n '1 6 7 5 2 4 3 8'\n \"\"\"\n for k in range(e-b):\n li[b+k], li[t+k] = li[t+k], li[b+k]\n\n\ndef run():\n n = int(input())\n li = input().split()\n assert(n == len(li))\n", "def swap_range(li, b, e, t):\n \"\"\"Swap element (b + k) and element (t + k) (0 <= k < e-b).\n\n >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']\n >>> swap_range(li, 1, 3, 5)\n >>> \" \".join(li)\n '1 6 7 4 5 2 3 8'\n >>> swap_range(li, 3, 5, 4)\n >>> \" \".join(li)\n '1 6 7 5 2 4 3 8'\n \"\"\"\n for k in range(e-b):\n li[b+k], li[t+k] = li[t+k], li[b+k]\n\n\ndef run():\n n = int(input())\n li = input().split()\n assert(n == len(li))\n\n q = int(input())\n", "def swap_range(li, b, e, t):\n \"\"\"Swap element (b + k) and element (t + k) (0 <= k < e-b).\n\n >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']\n >>> swap_range(li, 1, 3, 5)\n >>> \" \".join(li)\n '1 6 7 4 5 2 3 8'\n >>> swap_range(li, 3, 5, 4)\n >>> \" \".join(li)\n '1 6 7 5 2 4 3 8'\n \"\"\"\n for k in range(e-b):\n li[b+k], li[t+k] = li[t+k], li[b+k]\n\n\ndef run():\n n = int(input())\n li = input().split()\n assert(n == len(li))\n\n q = int(input())\n for _ in range(q):\n b, e, t = [int(x) for x in input().split()]\n", "def swap_range(li, b, e, t):\n \"\"\"Swap element (b + k) and element (t + k) (0 <= k < e-b).\n\n >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']\n >>> swap_range(li, 1, 3, 5)\n >>> \" \".join(li)\n '1 6 7 4 5 2 3 8'\n >>> swap_range(li, 3, 5, 4)\n >>> \" \".join(li)\n '1 6 7 5 2 4 3 8'\n \"\"\"\n for k in range(e-b):\n li[b+k], li[t+k] = li[t+k], li[b+k]\n\n\ndef run():\n n = int(input())\n li = input().split()\n assert(n == len(li))\n\n q = int(input())\n for _ in range(q):\n b, e, t = [int(x) for x in input().split()]\n swap_range(li, b, e, t)\n", "def swap_range(li, b, e, t):\n \"\"\"Swap element (b + k) and element (t + k) (0 <= k < e-b).\n\n >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']\n >>> swap_range(li, 1, 3, 5)\n >>> \" \".join(li)\n '1 6 7 4 5 2 3 8'\n >>> swap_range(li, 3, 5, 4)\n >>> \" \".join(li)\n '1 6 7 5 2 4 3 8'\n \"\"\"\n for k in range(e-b):\n li[b+k], li[t+k] = li[t+k], li[b+k]\n\n\ndef run():\n n = int(input())\n li = input().split()\n assert(n == len(li))\n\n q = int(input())\n for _ in range(q):\n b, e, t = [int(x) for x in input().split()]\n swap_range(li, b, e, t)\n\n print(\" \".join(li))\n", "def swap_range(li, b, e, t):\n \"\"\"Swap element (b + k) and element (t + k) (0 <= k < e-b).\n\n >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']\n >>> swap_range(li, 1, 3, 5)\n >>> \" \".join(li)\n '1 6 7 4 5 2 3 8'\n >>> swap_range(li, 3, 5, 4)\n >>> \" \".join(li)\n '1 6 7 5 2 4 3 8'\n \"\"\"\n for k in range(e-b):\n li[b+k], li[t+k] = li[t+k], li[b+k]\n\n\ndef run():\n n = int(input())\n li = input().split()\n assert(n == len(li))\n\n q = int(input())\n for _ in range(q):\n b, e, t = [int(x) for x in input().split()]\n swap_range(li, b, e, t)\n\n print(\" \".join(li))\n\n\nif __name__ == '__main__':\n run()\n", "\ndef swap_range(li, b, e, t):\n \"\"\"Swap element (b + k) and element (t + k) (0 <= k < e-b).\n\n >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']\n >>> swap_range(li, 1, 3, 5)\n >>> \" \".join(li)\n '1 6 7 4 5 2 3 8'\n >>> swap_range(li, 3, 5, 4)\n >>> \" \".join(li)\n '1 6 7 5 2 4 3 8'\n \"\"\"\n for k in range(e-b):\n li[b+k], li[t+k] = li[t+k], li[b+k]\n\n\ndef run():\n n = int(input())\n li = input().split()\n assert(n == len(li))\n\n q = int(input())\n for _ in range(q):\n b, e, t = [int(x) for x in input().split()]\n swap_range(li, b, e, t)\n\n print(\" \".join(li))\n\n\nif __name__ == '__main__':\n run()\n" ]
12
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "if __name__ == \"__main__\":\n num_a = int(input())\n a = list(map(lambda x: int(x), input().split()))\n num_query = int(input())\n\n for _ in range(num_query):\n begin, end, t = map(lambda x: int(x), input().split())\n for i, idx in enumerate(range(begin, end)):\n a[idx], a[t + i] = a[t + i], a[idx]\n\n print(\" \".join([str(elem) for elem in a]))\n" ]
2
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n=int(input())\n", "n=int(input())\na = list(map(int, input().split( )))\n", "n=int(input())\na = list(map(int, input().split( )))\nq=int(input())\n", "n=int(input())\na = list(map(int, input().split( )))\nq=int(input())\nfor _ in range(q):\n b,e,t = map(int, input().split( ))\n", "n=int(input())\na = list(map(int, input().split( )))\nq=int(input())\nfor _ in range(q):\n b,e,t = map(int, input().split( ))\n for k in range(e-b):\n tmp = a[b+k]\n", "n=int(input())\na = list(map(int, input().split( )))\nq=int(input())\nfor _ in range(q):\n b,e,t = map(int, input().split( ))\n for k in range(e-b):\n tmp = a[b+k]\n a[b+k] = a[t+k]\n", "n=int(input())\na = list(map(int, input().split( )))\nq=int(input())\nfor _ in range(q):\n b,e,t = map(int, input().split( ))\n for k in range(e-b):\n tmp = a[b+k]\n a[b+k] = a[t+k]\n a[t+k] = tmp\n", "n=int(input())\na = list(map(int, input().split( )))\nq=int(input())\nfor _ in range(q):\n b,e,t = map(int, input().split( ))\n for k in range(e-b):\n tmp = a[b+k]\n a[b+k] = a[t+k]\n a[t+k] = tmp\nprint(*a)\n" ]
9
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n=int(input())\n", "n=int(input())\ns=list(map(int,input().split()))\n", "n=int(input())\ns=list(map(int,input().split()))\nm=int(input())\n", "n=int(input())\ns=list(map(int,input().split()))\nm=int(input())\nfor i in range(m):\n b,e,t=map(int,input().split())\n", "n=int(input())\ns=list(map(int,input().split()))\nm=int(input())\nfor i in range(m):\n b,e,t=map(int,input().split())\n for k in range(e-b):\n s[b+k],s[t+k]=s[t+k],s[b+k]\n", "n=int(input())\ns=list(map(int,input().split()))\nm=int(input())\nfor i in range(m):\n b,e,t=map(int,input().split())\n for k in range(e-b):\n s[b+k],s[t+k]=s[t+k],s[b+k]\nprint(*s)\n" ]
7
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "def solve():\n from sys import stdin\n \n\nsolve()\n", "def solve():\n from sys import stdin\n f_i = stdin\n\n \nsolve()\n", "def solve():\n from sys import stdin\n f_i = stdin\n\n n = f_i.readline()\n \n \nsolve()\n", "def solve():\n from sys import stdin\n f_i = stdin\n\n n = f_i.readline()\n A = f_i.readline().split()\n \n \nsolve()\n", "def solve():\n from sys import stdin\n f_i = stdin\n\n n = f_i.readline()\n A = f_i.readline().split()\n q = int(f_i.readline())\n \n \nsolve()\n", "def solve():\n from sys import stdin\n f_i = stdin\n\n n = f_i.readline()\n A = f_i.readline().split()\n q = int(f_i.readline())\n for i in range(q):\n b, e, t = map(int, f_i.readline().split())\n \n \nsolve()\n", "def solve():\n from sys import stdin\n f_i = stdin\n\n n = f_i.readline()\n A = f_i.readline().split()\n q = int(f_i.readline())\n for i in range(q):\n b, e, t = map(int, f_i.readline().split())\n w = e - b\n \n \nsolve()\n", "def solve():\n from sys import stdin\n f_i = stdin\n\n n = f_i.readline()\n A = f_i.readline().split()\n q = int(f_i.readline())\n for i in range(q):\n b, e, t = map(int, f_i.readline().split())\n w = e - b\n if b < t:\n A = A[:b] + A[t:t+w] + A[b+w:t] + A[b:b+w] + A[t+w:]\n \n \nsolve()\n", "def solve():\n from sys import stdin\n f_i = stdin\n\n n = f_i.readline()\n A = f_i.readline().split()\n q = int(f_i.readline())\n for i in range(q):\n b, e, t = map(int, f_i.readline().split())\n w = e - b\n if b < t:\n A = A[:b] + A[t:t+w] + A[b+w:t] + A[b:b+w] + A[t+w:]\n else:\n A = A[:t] + A[b:b+w] + A[t+w:b] + A[t:t+w] + A[b+w:]\n \n\nsolve()\n", "def solve():\n from sys import stdin\n f_i = stdin\n\n n = f_i.readline()\n A = f_i.readline().split()\n q = int(f_i.readline())\n for i in range(q):\n b, e, t = map(int, f_i.readline().split())\n w = e - b\n if b < t:\n A = A[:b] + A[t:t+w] + A[b+w:t] + A[b:b+w] + A[t+w:]\n else:\n A = A[:t] + A[b:b+w] + A[t+w:b] + A[t:t+w] + A[b+w:]\n print(' '.join(A))\n\nsolve()\n" ]
11
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "def main():\n n = int(input())\n", "def main():\n n = int(input())\n A = list(map(int,input().split()))\n", "def main():\n n = int(input())\n A = list(map(int,input().split()))\n m = int(input())\n", "def main():\n n = int(input())\n A = list(map(int,input().split()))\n m = int(input())\n for _ in range(m):\n a,b,c = map(int,input().split())\n", "def main():\n n = int(input())\n A = list(map(int,input().split()))\n m = int(input())\n for _ in range(m):\n a,b,c = map(int,input().split())\n A[a:b],A[c:c+(b-a)] = A[c:c+(b-a)],A[a:b]\n", "def main():\n n = int(input())\n A = list(map(int,input().split()))\n m = int(input())\n for _ in range(m):\n a,b,c = map(int,input().split())\n A[a:b],A[c:c+(b-a)] = A[c:c+(b-a)],A[a:b]\n print (' '.join(map(str,A)))\n", "def main():\n n = int(input())\n A = list(map(int,input().split()))\n m = int(input())\n for _ in range(m):\n a,b,c = map(int,input().split())\n A[a:b],A[c:c+(b-a)] = A[c:c+(b-a)],A[a:b]\n print (' '.join(map(str,A)))\n\nif __name__ == '__main__':\n main()\n" ]
8
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "readline = open(0).readline\n", "readline = open(0).readline\nN = int(readline())\n", "readline = open(0).readline\nN = int(readline())\n*A, = map(int, readline().split())\n", "readline = open(0).readline\nN = int(readline())\n*A, = map(int, readline().split())\nQ = int(readline())\n", "readline = open(0).readline\nN = int(readline())\n*A, = map(int, readline().split())\nQ = int(readline())\nfor _ in range(Q):\n b, e, t = map(int, readline().split())\n", "readline = open(0).readline\nN = int(readline())\n*A, = map(int, readline().split())\nQ = int(readline())\nfor _ in range(Q):\n b, e, t = map(int, readline().split())\n for k in range(e-b):\n A[b+k], A[t+k] = A[t+k], A[b+k]\n", "readline = open(0).readline\nN = int(readline())\n*A, = map(int, readline().split())\nQ = int(readline())\nfor _ in range(Q):\n b, e, t = map(int, readline().split())\n for k in range(e-b):\n A[b+k], A[t+k] = A[t+k], A[b+k]\nprint(*A)\n" ]
8
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "input()\n", "input()\nnums = list(map(int, input().split(' ')))\n", "input()\nnums = list(map(int, input().split(' ')))\n\nn = int(input())\n", "input()\nnums = list(map(int, input().split(' ')))\n\nn = int(input())\nfor _ in range(n):\n f, m, l = list(map(int, input().split(' ')))\n m = m-f\n", "input()\nnums = list(map(int, input().split(' ')))\n\nn = int(input())\nfor _ in range(n):\n f, m, l = list(map(int, input().split(' ')))\n m = m-f\n if f > l:\n f, l = l, f\n", "input()\nnums = list(map(int, input().split(' ')))\n\nn = int(input())\nfor _ in range(n):\n f, m, l = list(map(int, input().split(' ')))\n m = m-f\n if f > l:\n f, l = l, f\n sb_1 = list(nums[f:f+m])\n", "input()\nnums = list(map(int, input().split(' ')))\n\nn = int(input())\nfor _ in range(n):\n f, m, l = list(map(int, input().split(' ')))\n m = m-f\n if f > l:\n f, l = l, f\n sb_1 = list(nums[f:f+m])\n sb_2 = list(nums[l:l+m])\n", "input()\nnums = list(map(int, input().split(' ')))\n\nn = int(input())\nfor _ in range(n):\n f, m, l = list(map(int, input().split(' ')))\n m = m-f\n if f > l:\n f, l = l, f\n sb_1 = list(nums[f:f+m])\n sb_2 = list(nums[l:l+m])\n\n nums = nums[:f] + sb_2 + nums[f+m:l] + sb_1 + nums[l+m:]\n", "input()\nnums = list(map(int, input().split(' ')))\n\nn = int(input())\nfor _ in range(n):\n f, m, l = list(map(int, input().split(' ')))\n m = m-f\n if f > l:\n f, l = l, f\n sb_1 = list(nums[f:f+m])\n sb_2 = list(nums[l:l+m])\n\n nums = nums[:f] + sb_2 + nums[f+m:l] + sb_1 + nums[l+m:]\n\nprint(' '.join(map(str, nums)))\n" ]
10
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "n = int(input())\n", "n = int(input())\narr = input().split()\n", "n = int(input())\narr = input().split()\nnq = int(input())\n", "n = int(input())\narr = input().split()\nnq = int(input())\n\nfor i in range(nq):\n begin, end, tgt = map(int, input().split())\n", "n = int(input())\narr = input().split()\nnq = int(input())\n\nfor i in range(nq):\n begin, end, tgt = map(int, input().split())\n length = end - begin\n", "n = int(input())\narr = input().split()\nnq = int(input())\n\nfor i in range(nq):\n begin, end, tgt = map(int, input().split())\n length = end - begin\n if begin < tgt:\n arr = arr[:begin] + arr[tgt:tgt+length] + arr[end:tgt] + arr[begin:end] + arr[tgt+length:]\n", "n = int(input())\narr = input().split()\nnq = int(input())\n\nfor i in range(nq):\n begin, end, tgt = map(int, input().split())\n length = end - begin\n if begin < tgt:\n arr = arr[:begin] + arr[tgt:tgt+length] + arr[end:tgt] + arr[begin:end] + arr[tgt+length:]\n else:\n arr = arr[:tgt] + arr[begin:end] + arr[tgt+length:begin] + arr[tgt:tgt+length] + arr[end:]\n", "n = int(input())\narr = input().split()\nnq = int(input())\n\nfor i in range(nq):\n begin, end, tgt = map(int, input().split())\n length = end - begin\n if begin < tgt:\n arr = arr[:begin] + arr[tgt:tgt+length] + arr[end:tgt] + arr[begin:end] + arr[tgt+length:]\n else:\n arr = arr[:tgt] + arr[begin:end] + arr[tgt+length:begin] + arr[tgt:tgt+length] + arr[end:]\n\nprint(*arr)\n" ]
9
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "# coding=utf-8\n", "# coding=utf-8\n\n\ndef partial_swap(origin, begin, end, begin2):\n for i in range(end-begin):\n origin[begin+i], origin[begin2+i] = origin[begin2+i], origin[begin+i]\n", "# coding=utf-8\n\n\ndef partial_swap(origin, begin, end, begin2):\n for i in range(end-begin):\n origin[begin+i], origin[begin2+i] = origin[begin2+i], origin[begin+i]\n\n return origin\n", "# coding=utf-8\n\n\ndef partial_swap(origin, begin, end, begin2):\n for i in range(end-begin):\n origin[begin+i], origin[begin2+i] = origin[begin2+i], origin[begin+i]\n\n return origin\n\n\nif __name__ == '__main__':\n N = int(input())\n", "# coding=utf-8\n\n\ndef partial_swap(origin, begin, end, begin2):\n for i in range(end-begin):\n origin[begin+i], origin[begin2+i] = origin[begin2+i], origin[begin+i]\n\n return origin\n\n\nif __name__ == '__main__':\n N = int(input())\n A = list(map(int, input().split()))\n", "# coding=utf-8\n\n\ndef partial_swap(origin, begin, end, begin2):\n for i in range(end-begin):\n origin[begin+i], origin[begin2+i] = origin[begin2+i], origin[begin+i]\n\n return origin\n\n\nif __name__ == '__main__':\n N = int(input())\n A = list(map(int, input().split()))\n Q = int(input())\n", "# coding=utf-8\n\n\ndef partial_swap(origin, begin, end, begin2):\n for i in range(end-begin):\n origin[begin+i], origin[begin2+i] = origin[begin2+i], origin[begin+i]\n\n return origin\n\n\nif __name__ == '__main__':\n N = int(input())\n A = list(map(int, input().split()))\n Q = int(input())\n\n for i in range(Q):\n b, e, t = map(int, input().split())\n", "# coding=utf-8\n\n\ndef partial_swap(origin, begin, end, begin2):\n for i in range(end-begin):\n origin[begin+i], origin[begin2+i] = origin[begin2+i], origin[begin+i]\n\n return origin\n\n\nif __name__ == '__main__':\n N = int(input())\n A = list(map(int, input().split()))\n Q = int(input())\n\n for i in range(Q):\n b, e, t = map(int, input().split())\n A = partial_swap(A, b, e, t)\n", "# coding=utf-8\n\n\ndef partial_swap(origin, begin, end, begin2):\n for i in range(end-begin):\n origin[begin+i], origin[begin2+i] = origin[begin2+i], origin[begin+i]\n\n return origin\n\n\nif __name__ == '__main__':\n N = int(input())\n A = list(map(int, input().split()))\n Q = int(input())\n\n for i in range(Q):\n b, e, t = map(int, input().split())\n A = partial_swap(A, b, e, t)\n\n print(' '.join(map(str, A)))\n" ]
10
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$. Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a_i \leq 1,000,000,000$ * $1 \leq q \leq 1,000$ * $0 \leq b_i < e_i \leq n$ * $0 \leq t_i < t_i + (e_i - b_i) \leq n$ * Given swap ranges do not overlap each other Input The input is given in the following format. $n$ $a_0 \; a_1 \; ...,\; a_{n-1}$ $q$ $b_1 \; e_1 \; t_1$ $b_2 \; e_2 \; t_2$ : $b_{q} \; e_{q} \; t_{q}$ In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines. Output Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element. Example Input 11 1 2 3 4 5 6 7 8 9 10 11 1 1 4 7 Output 1 8 9 10 5 6 7 2 3 4 11
[ "\n", "from copy import deepcopy\n", "from copy import deepcopy\nn = int(input())\n", "from copy import deepcopy\nn = int(input())\na = list(map(int,input().split()))\n", "from copy import deepcopy\nn = int(input())\na = list(map(int,input().split()))\n\nfor i in range(int(input())):\n b,e,t = map(int,input().split())\n", "from copy import deepcopy\nn = int(input())\na = list(map(int,input().split()))\n\nfor i in range(int(input())):\n b,e,t = map(int,input().split())\n tmp = deepcopy(a)\n", "from copy import deepcopy\nn = int(input())\na = list(map(int,input().split()))\n\nfor i in range(int(input())):\n b,e,t = map(int,input().split())\n tmp = deepcopy(a)\n for k in range(e-b):\n a[t+k] = tmp[b+k]\n", "from copy import deepcopy\nn = int(input())\na = list(map(int,input().split()))\n\nfor i in range(int(input())):\n b,e,t = map(int,input().split())\n tmp = deepcopy(a)\n for k in range(e-b):\n a[t+k] = tmp[b+k]\n a[b+k] = tmp[t+k]\n", "from copy import deepcopy\nn = int(input())\na = list(map(int,input().split()))\n\nfor i in range(int(input())):\n b,e,t = map(int,input().split())\n tmp = deepcopy(a)\n for k in range(e-b):\n a[t+k] = tmp[b+k]\n a[b+k] = tmp[t+k]\n\nprint(*a)\n" ]
9
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 3 4 11" } ]
[ { "input": "11\n1 2 3 4 5 6 7 8 9 10 11\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 11\n" }, { "input": "11\n1 2 3 4 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 2 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 18 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 2 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 2 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 2 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 2 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 21\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 0 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 0 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 0 2 14 10 21\n0\n-1 -2 0", "output": "-2 0 16 -1 4 6 0 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 7 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 7 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 13\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 13\n" }, { "input": "11\n1 2 3 4 5 6 7 8 10 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 10 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 8 9 10 11\n" }, { "input": "11\n1 2 3 3 5 6 2 8 18 10 11\n2\n2 4 1", "output": "1 3 2 3 5 6 2 8 18 10 11\n" }, { "input": "11\n1 0 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 0 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 8 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 8 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n1 4 1", "output": "1 0 5 3 5 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 5 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 5 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 3 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 3 5 6 1 8 14 10 11\n" }, { "input": "11\n1 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 1 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 11\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 10 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 10 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 1 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 1 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 14 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 14 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 14 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 21\n0\n0 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 21\n" }, { "input": "11\n-1 0 3 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 3 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 2 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 2 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 10 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 10 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "-2 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 10 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 10 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n1 4 7", "output": "1 8 9 10 5 6 14 2 4 4 11\n" }, { "input": "11\n1 2 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 2 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 6 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 6 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 0 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 0 8 9 12 11\n" }, { "input": "11\n1 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 1 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 5 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 10 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 10 11\n" }, { "input": "11\n1 0 3 3 5 6 2 2 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 2 14 12 11\n" }, { "input": "11\n1 0 5 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 5 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 4 1", "output": "5 3 5 1 0 6 1 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 6 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 6 1 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 8 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 8 14 10 11\n" }, { "input": "11\n0 0 9 3 5 6 1 2 14 10 11\n0\n1 4 1", "output": "0 0 9 3 5 6 1 2 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 10 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 10 11\n" }, { "input": "11\n1 0 5 3 1 6 0 2 14 10 11\n0\n1 4 1", "output": "1 0 5 3 1 6 0 2 14 10 11\n" }, { "input": "11\n0 0 10 3 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 3 2 7 1 2 14 10 7\n" }, { "input": "11\n0 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 0 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 21\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 21\n" }, { "input": "11\n0 0 10 4 2 6 2 2 14 10 21\n0\n0 4 0", "output": "0 0 10 4 2 6 2 2 14 10 21\n" }, { "input": "11\n0 0 10 3 2 6 0 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 0 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 0 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 0 10 7\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 21\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 14 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 14 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 2 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 2 14 10 21\n" }, { "input": "11\n0 0 10 -1 4 6 -1 2 14 10 21\n0\n-1 -1 0", "output": "0 0 10 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n-2 0 19 -1 4 6 0 2 16 10 21\n0\n-1 -2 0", "output": "-2 0 19 -1 4 6 0 2 16 10 21\n" }, { "input": "11\n-2 0 16 -1 4 6 -1 2 14 10 21\n0\n-1 -4 0", "output": "-2 0 16 -1 4 6 -1 2 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 8 9 10 11\n1\n0 4 7", "output": "8 9 10 11 5 6 14 1 2 4 4\n" }, { "input": "11\n1 0 3 4 5 6 7 8 9 10 7\n2\n1 4 7", "output": "1 0 3 4 5 6 7 8 9 10 7\n" }, { "input": "11\n1 2 3 4 5 0 7 8 1 10 11\n2\n1 4 1", "output": "1 2 3 4 5 0 7 8 1 10 11\n" }, { "input": "11\n1 2 3 4 5 6 1 8 9 12 11\n2\n1 4 1", "output": "1 2 3 4 5 6 1 8 9 12 11\n" }, { "input": "11\n0 2 3 3 5 6 2 15 9 10 11\n2\n0 4 1", "output": "3 3 5 0 2 6 2 15 9 10 11\n" }, { "input": "11\n1 0 3 3 9 6 2 4 18 10 11\n2\n1 1 1", "output": "1 0 3 3 9 6 2 4 18 10 11\n" }, { "input": "11\n1 1 3 3 5 12 2 8 34 7 11\n2\n1 4 1", "output": "1 1 3 3 5 12 2 8 34 7 11\n" }, { "input": "11\n1 0 3 3 5 6 2 4 14 12 11\n2\n1 4 1", "output": "1 0 3 3 5 6 2 4 14 12 11\n" }, { "input": "11\n1 0 9 3 5 6 2 5 14 10 11\n4\n1 4 1", "output": "1 0 9 3 5 6 2 5 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 1 8 10 10 11\n2\n0 6 1", "output": "5 3 5 6 1 1 0 8 10 10 11\n" }, { "input": "11\n0 0 5 3 7 1 1 8 14 10 11\n2\n0 4 1", "output": "5 3 7 0 0 1 1 8 14 10 11\n" }, { "input": "11\n1 0 5 3 5 6 0 8 14 10 11\n0\n0 6 0", "output": "1 0 5 3 5 6 0 8 14 10 11\n" }, { "input": "11\n2 0 5 6 5 6 1 5 14 10 11\n0\n1 4 1", "output": "2 0 5 6 5 6 1 5 14 10 11\n" }, { "input": "11\n0 0 6 3 5 6 1 2 14 15 11\n0\n1 5 1", "output": "0 0 6 3 5 6 1 2 14 15 11\n" }, { "input": "11\n0 0 10 5 2 7 1 2 14 10 7\n0\n1 4 1", "output": "0 0 10 5 2 7 1 2 14 10 7\n" }, { "input": "11\n1 0 10 3 2 6 1 2 14 20 11\n1\n1 4 0", "output": "0 10 3 1 2 6 1 2 14 20 11\n" }, { "input": "11\n0 0 1 3 2 6 1 2 14 17 14\n0\n1 4 0", "output": "0 0 1 3 2 6 1 2 14 17 14\n" }, { "input": "11\n0 0 10 3 2 6 1 0 12 10 21\n0\n0 4 0", "output": "0 0 10 3 2 6 1 0 12 10 21\n" }, { "input": "11\n-1 0 10 3 4 6 0 2 1 10 7\n0\n0 4 0", "output": "-1 0 10 3 4 6 0 2 1 10 7\n" }, { "input": "11\n-1 0 10 3 4 11 0 2 14 10 36\n0\n1 0 0", "output": "-1 0 10 3 4 11 0 2 14 10 36\n" }, { "input": "11\n-1 0 1 3 4 6 0 2 14 10 29\n0\n0 -1 0", "output": "-1 0 1 3 4 6 0 2 14 10 29\n" }, { "input": "11\n-1 0 10 3 4 6 1 2 8 10 21\n0\n0 -1 0", "output": "-1 0 10 3 4 6 1 2 8 10 21\n" }, { "input": "11\n-1 0 20 -1 0 6 0 4 14 10 21\n0\n-1 -1 0", "output": "-1 0 20 -1 0 6 0 4 14 10 21\n" }, { "input": "11\n1 2 4 4 5 6 14 11 9 10 11\n1\n0 4 7", "output": "11 9 10 11 5 6 14 1 2 4 4\n" } ]
0/::0
Takahashi and Aoki love calculating things, so they will play with numbers now. First, they came up with one positive integer each. Takahashi came up with X, and Aoki came up with Y. Then, they will enjoy themselves by repeating the following operation K times: * Compute the bitwise AND of the number currently kept by Takahashi and the number currently kept by Aoki. Let Z be the result. * Then, add Z to both of the numbers kept by Takahashi and Aoki. However, it turns out that even for the two math maniacs this is just too much work. Could you find the number that would be kept by Takahashi and the one that would be kept by Aoki eventually? Note that input and output are done in binary. Especially, X and Y are given as strings S and T of length N and M consisting of `0` and `1`, respectively, whose initial characters are guaranteed to be `1`. Constraints * 1 ≤ K ≤ 10^6 * 1 ≤ N,M ≤ 10^6 * The initial characters of S and T are `1`. Input Input is given from Standard Input in the following format: N M K S T Output In the first line, print the number that would be kept by Takahashi eventually; in the second line, print the number that would be kept by Aoki eventually. Those numbers should be represented in binary and printed as strings consisting of `0` and `1` that begin with `1`. Examples Input 2 3 3 11 101 Output 10000 10010 Input 5 8 3 10101 10101001 Output 100000 10110100 Input 10 10 10 1100110011 1011001101 Output 10000100000010001000 10000100000000100010
[ "\n", "def Z():\n m=-1;I=input;N,M,K=map(int,I().split());W=2000000;s=[0]*W;t=[0]*W;L=max(N,M)-1;R=range;p=lambda x:print(*reversed(x),sep='')\n for i,c in zip(R(N-1,m,m),I()):s[i]=int(c)\n for i,c in zip(R(M-1,m,m),I()):t[i]=int(c)\n for i in R(L,m,m):\n j=i;z=K\n while s[j]and t[j]and z:\n s[j]=t[j]=0;s[j+1]+=1;t[j+1]+=1;j+=1;z-=1;x=y=j\n while s[x]==2:s[x]=0;s[x+1]+=1;x+=1\n while t[y]==2:t[y]=0;t[y+1]+=1;y+=1\n j=max(x,y)\n L=max(L,j)\n s=s[:L+1];t=t[:L+1]\n while s[m]==0:s.pop()\n while t[m]==0:t.pop()\n p(s);p(t)\nZ()\n" ]
2
[ { "input": "2 3 3\n11\n101", "output": "10000\n10010" }, { "input": "10 10 10\n1100110011\n1011001101", "output": "10000100000010001000\n10000100000000100010" }, { "input": "5 8 3\n10101\n10101001", "output": "100000\n10110100" } ]
[ { "input": "5 8 3\n00101\n10101001", "output": "10000\n10110100\n" }, { "input": "5 8 3\n00101\n10100001", "output": "1000\n10100100\n" }, { "input": "5 8 5\n00101\n10110001", "output": "1000\n10110100\n" }, { "input": "5 8 5\n00101\n10110011", "output": "10010\n11000000\n" }, { "input": "5 8 3\n10101\n10100001", "output": "11000\n10100100\n" }, { "input": "5 8 3\n00100\n10101001", "output": "100\n10101001\n" }, { "input": "5 8 5\n00101\n10000001", "output": "1000\n10000100\n" }, { "input": "5 8 5\n10101\n10110001", "output": "101000\n11000100\n" }, { "input": "10 10 14\n1100110011\n1011001101", "output": "100001000000000010001000\n100001000000000000100010\n" }, { "input": "5 8 3\n10101\n10111001", "output": "110000\n11010100\n" }, { "input": "5 8 2\n00101\n10101001", "output": "1000\n10101100\n" }, { "input": "5 8 5\n00001\n10110011", "output": "10\n10110100\n" }, { "input": "5 8 3\n01100\n10101001", "output": "100100\n11000001\n" }, { "input": "5 8 5\n10101\n00110001", "output": "101000\n1000100\n" }, { "input": "10 10 14\n1110110011\n1011001101", "output": "100001000000000100001000\n100001000000000000100010\n" }, { "input": "5 8 5\n00001\n10110111", "output": "10\n10111000\n" }, { "input": "5 8 5\n00101\n00110001", "output": "1000\n110100\n" }, { "input": "5 8 5\n00111\n00110001", "output": "1000\n110010\n" }, { "input": "5 8 5\n00111\n00100001", "output": "1000\n100010\n" }, { "input": "5 8 5\n10111\n00100001", "output": "11000\n100010\n" }, { "input": "2 3 2\n11\n101", "output": "1000\n1010\n" }, { "input": "5 8 3\n10101\n10001001", "output": "100000\n10010100\n" }, { "input": "5 8 3\n00001\n10101001", "output": "1000\n10110000\n" }, { "input": "5 8 5\n00100\n10100001", "output": "100\n10100001\n" }, { "input": "5 8 5\n00100\n10110011", "output": "100\n10110011\n" }, { "input": "5 8 3\n00111\n10101001", "output": "100000\n11000010\n" }, { "input": "5 8 5\n00111\n10000001", "output": "1000\n10000010\n" }, { "input": "10 10 5\n1100110011\n1011001101", "output": "100001010001000\n100001000100010\n" }, { "input": "5 8 3\n10101\n10111000", "output": "100101\n11001000\n" }, { "input": "5 8 2\n10101\n10101001", "output": "11000\n10101100\n" }, { "input": "10 10 3\n1110110011\n1011001101", "output": "1001001001000\n1000101100010\n" }, { "input": "5 8 5\n00101\n00110011", "output": "10010\n1000000\n" }, { "input": "5 8 5\n11111\n00100001", "output": "1000000000\n1000000010\n" }, { "input": "5 8 3\n00011\n10101001", "output": "100\n10101010\n" }, { "input": "5 8 5\n00100\n10110010", "output": "100\n10110010\n" }, { "input": "5 8 5\n00011\n10000001", "output": "100\n10000010\n" }, { "input": "10 10 5\n1101110011\n1011001101", "output": "101000011001000\n101000000100010\n" }, { "input": "5 8 5\n11111\n00110001", "output": "110000\n1000010\n" }, { "input": "5 8 4\n00101\n10001001", "output": "100000\n10100100\n" }, { "input": "5 8 4\n00101\n10000000", "output": "101\n10000000\n" }, { "input": "5 8 8\n10100\n10100001", "output": "10100\n10100001\n" }, { "input": "5 8 5\n10011\n10000001", "output": "10100\n10000010\n" }, { "input": "10 10 5\n1101110011\n1111001101", "output": "110000011001000\n110000100100010\n" }, { "input": "5 8 5\n11111\n01110001", "output": "110000\n10000010\n" }, { "input": "5 8 4\n00100\n10001001", "output": "100\n10001001\n" }, { "input": "5 8 4\n10101\n10000000", "output": "10101\n10000000\n" }, { "input": "10 10 1\n1101110011\n1111001101", "output": "11010110100\n11100001110\n" }, { "input": "5 8 4\n10101\n10000001", "output": "11000\n10000100\n" }, { "input": "5 8 5\n11111\n01100001", "output": "1000000\n10000010\n" }, { "input": "5 8 8\n00110\n10110011", "output": "1000\n10110101\n" }, { "input": "5 8 4\n11101\n10000001", "output": "100000\n10000100\n" }, { "input": "5 8 4\n01101\n10000001", "output": "10000\n10000100\n" }, { "input": "5 8 9\n11111\n01100011", "output": "1000100\n10001000\n" }, { "input": "5 8 9\n01111\n01100011", "output": "10100\n1101000\n" }, { "input": "2 3 3\n11\n001", "output": "100\n10\n" }, { "input": "5 8 5\n00101\n10100011", "output": "100010\n11000000\n" }, { "input": "5 8 1\n00101\n10110011", "output": "110\n10110100\n" }, { "input": "5 8 3\n10100\n10101001", "output": "10100\n10101001\n" }, { "input": "5 8 5\n00100\n10000001", "output": "100\n10000001\n" }, { "input": "10 10 4\n1100110011\n1011001101", "output": "10000110001000\n10000100100010\n" }, { "input": "5 8 2\n00101\n10101000", "output": "101\n10101000\n" }, { "input": "5 8 3\n01100\n00101001", "output": "100100\n1000001\n" }, { "input": "10 10 14\n1110010011\n1011001101", "output": "100000000000001001001000\n100000000000000110000010\n" }, { "input": "5 8 5\n10001\n10110111", "output": "100010\n11001000\n" }, { "input": "2 3 2\n11\n111", "output": "1000\n1100\n" }, { "input": "5 8 5\n00100\n11110011", "output": "100\n11110011\n" }, { "input": "5 8 3\n00111\n10111001", "output": "10000\n11000010\n" }, { "input": "10 10 5\n1100110011\n1011001111", "output": "100010010001000\n100010000100100\n" }, { "input": "5 8 2\n10001\n10101001", "output": "10100\n10101100\n" }, { "input": "5 8 5\n00101\n01110011", "output": "10010\n10000000\n" }, { "input": "5 8 4\n10101\n10001000", "output": "10101\n10001000\n" }, { "input": "5 8 4\n00111\n10101101", "output": "1100\n10110010\n" }, { "input": "5 8 4\n00101\n10100000", "output": "101\n10100000\n" }, { "input": "10 10 6\n1101110011\n1111001101", "output": "1100000011001000\n1100000100100010\n" }, { "input": "5 8 4\n10101\n10000100", "output": "100001\n10010000\n" }, { "input": "5 8 4\n01101\n10000000", "output": "1101\n10000000\n" }, { "input": "5 8 3\n11101\n10110001", "output": "110000\n11000100\n" }, { "input": "10 10 4\n1000110011\n1011001101", "output": "10000010001000\n10000100100010\n" }, { "input": "5 8 2\n10101\n10101000", "output": "10101\n10101000\n" }, { "input": "5 8 4\n01100\n10100001", "output": "1100\n10100001\n" }, { "input": "2 3 1\n11\n111", "output": "110\n1010\n" }, { "input": "5 8 8\n00100\n11101001", "output": "100\n11101001\n" }, { "input": "5 8 4\n00111\n10101111", "output": "101000\n11010000\n" }, { "input": "10 10 6\n1101110011\n1111001100", "output": "1100000010110011\n1100000100001100\n" }, { "input": "5 8 1\n10101\n10000100", "output": "11001\n10001000\n" }, { "input": "5 8 6\n00100\n10110001", "output": "100\n10110001\n" }, { "input": "5 8 2\n10101\n00101000", "output": "10101\n101000\n" }, { "input": "5 8 4\n11100\n10100001", "output": "11100\n10100001\n" }, { "input": "5 8 8\n01100\n11101001", "output": "100100\n100000001\n" }, { "input": "5 8 4\n00110\n10101111", "output": "100000\n11001001\n" }, { "input": "5 8 2\n00001\n10100000", "output": "1\n10100000\n" }, { "input": "10 10 6\n1101110011\n0111001100", "output": "10010110011\n1100001100\n" }, { "input": "5 8 6\n11100\n10110001", "output": "101100\n11000001\n" }, { "input": "5 8 2\n00101\n00101000", "output": "101\n101000\n" }, { "input": "5 8 31\n00101\n00000001", "output": "1000\n100\n" }, { "input": "5 8 8\n01100\n01101001", "output": "100100\n10000001\n" }, { "input": "10 10 6\n1111110011\n0111001100", "output": "100010000110011\n100001000001100\n" }, { "input": "5 8 2\n00101\n00001000", "output": "101\n1000\n" }, { "input": "5 8 0\n10100\n10100000", "output": "10100\n10100000\n" }, { "input": "5 8 31\n00111\n00000001", "output": "1000\n10\n" } ]
0/::0
Takahashi and Aoki love calculating things, so they will play with numbers now. First, they came up with one positive integer each. Takahashi came up with X, and Aoki came up with Y. Then, they will enjoy themselves by repeating the following operation K times: * Compute the bitwise AND of the number currently kept by Takahashi and the number currently kept by Aoki. Let Z be the result. * Then, add Z to both of the numbers kept by Takahashi and Aoki. However, it turns out that even for the two math maniacs this is just too much work. Could you find the number that would be kept by Takahashi and the one that would be kept by Aoki eventually? Note that input and output are done in binary. Especially, X and Y are given as strings S and T of length N and M consisting of `0` and `1`, respectively, whose initial characters are guaranteed to be `1`. Constraints * 1 ≤ K ≤ 10^6 * 1 ≤ N,M ≤ 10^6 * The initial characters of S and T are `1`. Input Input is given from Standard Input in the following format: N M K S T Output In the first line, print the number that would be kept by Takahashi eventually; in the second line, print the number that would be kept by Aoki eventually. Those numbers should be represented in binary and printed as strings consisting of `0` and `1` that begin with `1`. Examples Input 2 3 3 11 101 Output 10000 10010 Input 5 8 3 10101 10101001 Output 100000 10110100 Input 10 10 10 1100110011 1011001101 Output 10000100000010001000 10000100000000100010
[ "\n", "def main():\n N, M, K = map(int, input().split())\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n \n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n \n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n \n \n j += 1\n z -= 1\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n \n \n j += 1\n z -= 1\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n \n j += 1\n z -= 1\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n \n \n js += 1\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n \n js += 1\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n while t[jt] == 2:\n \n \n jt += 1\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n while t[jt] == 2:\n t[jt] = 0\n \n jt += 1\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n while t[jt] == 2:\n t[jt] = 0\n t[jt + 1] += 1\n jt += 1\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n while t[jt] == 2:\n t[jt] = 0\n t[jt + 1] += 1\n jt += 1\n\n j = max(js, jt)\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n while t[jt] == 2:\n t[jt] = 0\n t[jt + 1] += 1\n jt += 1\n\n j = max(js, jt)\n\n len_max = max(len_max, j)\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n while t[jt] == 2:\n t[jt] = 0\n t[jt + 1] += 1\n jt += 1\n\n j = max(js, jt)\n\n len_max = max(len_max, j)\n\n s = s[:len_max + 1]\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n while t[jt] == 2:\n t[jt] = 0\n t[jt + 1] += 1\n jt += 1\n\n j = max(js, jt)\n\n len_max = max(len_max, j)\n\n s = s[:len_max + 1]\n t = t[:len_max + 1]\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n while t[jt] == 2:\n t[jt] = 0\n t[jt + 1] += 1\n jt += 1\n\n j = max(js, jt)\n\n len_max = max(len_max, j)\n\n s = s[:len_max + 1]\n t = t[:len_max + 1]\n\n while not s[-1]:\n s.pop()\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n while t[jt] == 2:\n t[jt] = 0\n t[jt + 1] += 1\n jt += 1\n\n j = max(js, jt)\n\n len_max = max(len_max, j)\n\n s = s[:len_max + 1]\n t = t[:len_max + 1]\n\n while not s[-1]:\n s.pop()\n while not t[-1]:\n t.pop()\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n while t[jt] == 2:\n t[jt] = 0\n t[jt + 1] += 1\n jt += 1\n\n j = max(js, jt)\n\n len_max = max(len_max, j)\n\n s = s[:len_max + 1]\n t = t[:len_max + 1]\n\n while not s[-1]:\n s.pop()\n while not t[-1]:\n t.pop()\n\n print(*reversed(s), sep='')\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n\n for i in range(len_max, -1, -1):\n j = i\n z = K\n while s[j] and t[j] and z:\n s[j] = t[j] = 0\n s[j + 1] += 1\n t[j + 1] += 1\n j += 1\n z -= 1\n js = jt = j\n\n while s[js] == 2:\n s[js] = 0\n s[js + 1] += 1\n js += 1\n\n while t[jt] == 2:\n t[jt] = 0\n t[jt + 1] += 1\n jt += 1\n\n j = max(js, jt)\n\n len_max = max(len_max, j)\n\n s = s[:len_max + 1]\n t = t[:len_max + 1]\n\n while not s[-1]:\n s.pop()\n while not t[-1]:\n t.pop()\n\n print(*reversed(s), sep='')\n print(*reversed(t), sep='')\n\nmain()\n" ]
28
[ { "input": "2 3 3\n11\n101", "output": "10000\n10010" }, { "input": "10 10 10\n1100110011\n1011001101", "output": "10000100000010001000\n10000100000000100010" }, { "input": "5 8 3\n10101\n10101001", "output": "100000\n10110100" } ]
[ { "input": "5 8 3\n00101\n10101001", "output": "10000\n10110100\n" }, { "input": "5 8 3\n00101\n10100001", "output": "1000\n10100100\n" }, { "input": "5 8 5\n00101\n10110001", "output": "1000\n10110100\n" }, { "input": "5 8 5\n00101\n10110011", "output": "10010\n11000000\n" }, { "input": "5 8 3\n10101\n10100001", "output": "11000\n10100100\n" }, { "input": "5 8 3\n00100\n10101001", "output": "100\n10101001\n" }, { "input": "5 8 5\n00101\n10000001", "output": "1000\n10000100\n" }, { "input": "5 8 5\n10101\n10110001", "output": "101000\n11000100\n" }, { "input": "10 10 14\n1100110011\n1011001101", "output": "100001000000000010001000\n100001000000000000100010\n" }, { "input": "5 8 3\n10101\n10111001", "output": "110000\n11010100\n" }, { "input": "5 8 2\n00101\n10101001", "output": "1000\n10101100\n" }, { "input": "5 8 5\n00001\n10110011", "output": "10\n10110100\n" }, { "input": "5 8 3\n01100\n10101001", "output": "100100\n11000001\n" }, { "input": "5 8 5\n10101\n00110001", "output": "101000\n1000100\n" }, { "input": "10 10 14\n1110110011\n1011001101", "output": "100001000000000100001000\n100001000000000000100010\n" }, { "input": "5 8 5\n00001\n10110111", "output": "10\n10111000\n" }, { "input": "5 8 5\n00101\n00110001", "output": "1000\n110100\n" }, { "input": "5 8 5\n00111\n00110001", "output": "1000\n110010\n" }, { "input": "5 8 5\n00111\n00100001", "output": "1000\n100010\n" }, { "input": "5 8 5\n10111\n00100001", "output": "11000\n100010\n" }, { "input": "2 3 2\n11\n101", "output": "1000\n1010\n" }, { "input": "5 8 3\n10101\n10001001", "output": "100000\n10010100\n" }, { "input": "5 8 3\n00001\n10101001", "output": "1000\n10110000\n" }, { "input": "5 8 5\n00100\n10100001", "output": "100\n10100001\n" }, { "input": "5 8 5\n00100\n10110011", "output": "100\n10110011\n" }, { "input": "5 8 3\n00111\n10101001", "output": "100000\n11000010\n" }, { "input": "5 8 5\n00111\n10000001", "output": "1000\n10000010\n" }, { "input": "10 10 5\n1100110011\n1011001101", "output": "100001010001000\n100001000100010\n" }, { "input": "5 8 3\n10101\n10111000", "output": "100101\n11001000\n" }, { "input": "5 8 2\n10101\n10101001", "output": "11000\n10101100\n" }, { "input": "10 10 3\n1110110011\n1011001101", "output": "1001001001000\n1000101100010\n" }, { "input": "5 8 5\n00101\n00110011", "output": "10010\n1000000\n" }, { "input": "5 8 5\n11111\n00100001", "output": "1000000000\n1000000010\n" }, { "input": "5 8 3\n00011\n10101001", "output": "100\n10101010\n" }, { "input": "5 8 5\n00100\n10110010", "output": "100\n10110010\n" }, { "input": "5 8 5\n00011\n10000001", "output": "100\n10000010\n" }, { "input": "10 10 5\n1101110011\n1011001101", "output": "101000011001000\n101000000100010\n" }, { "input": "5 8 5\n11111\n00110001", "output": "110000\n1000010\n" }, { "input": "5 8 4\n00101\n10001001", "output": "100000\n10100100\n" }, { "input": "5 8 4\n00101\n10000000", "output": "101\n10000000\n" }, { "input": "5 8 8\n10100\n10100001", "output": "10100\n10100001\n" }, { "input": "5 8 5\n10011\n10000001", "output": "10100\n10000010\n" }, { "input": "10 10 5\n1101110011\n1111001101", "output": "110000011001000\n110000100100010\n" }, { "input": "5 8 5\n11111\n01110001", "output": "110000\n10000010\n" }, { "input": "5 8 4\n00100\n10001001", "output": "100\n10001001\n" }, { "input": "5 8 4\n10101\n10000000", "output": "10101\n10000000\n" }, { "input": "10 10 1\n1101110011\n1111001101", "output": "11010110100\n11100001110\n" }, { "input": "5 8 4\n10101\n10000001", "output": "11000\n10000100\n" }, { "input": "5 8 5\n11111\n01100001", "output": "1000000\n10000010\n" }, { "input": "5 8 8\n00110\n10110011", "output": "1000\n10110101\n" }, { "input": "5 8 4\n11101\n10000001", "output": "100000\n10000100\n" }, { "input": "5 8 4\n01101\n10000001", "output": "10000\n10000100\n" }, { "input": "5 8 9\n11111\n01100011", "output": "1000100\n10001000\n" }, { "input": "5 8 9\n01111\n01100011", "output": "10100\n1101000\n" }, { "input": "2 3 3\n11\n001", "output": "100\n10\n" }, { "input": "5 8 5\n00101\n10100011", "output": "100010\n11000000\n" }, { "input": "5 8 1\n00101\n10110011", "output": "110\n10110100\n" }, { "input": "5 8 3\n10100\n10101001", "output": "10100\n10101001\n" }, { "input": "5 8 5\n00100\n10000001", "output": "100\n10000001\n" }, { "input": "10 10 4\n1100110011\n1011001101", "output": "10000110001000\n10000100100010\n" }, { "input": "5 8 2\n00101\n10101000", "output": "101\n10101000\n" }, { "input": "5 8 3\n01100\n00101001", "output": "100100\n1000001\n" }, { "input": "10 10 14\n1110010011\n1011001101", "output": "100000000000001001001000\n100000000000000110000010\n" }, { "input": "5 8 5\n10001\n10110111", "output": "100010\n11001000\n" }, { "input": "2 3 2\n11\n111", "output": "1000\n1100\n" }, { "input": "5 8 5\n00100\n11110011", "output": "100\n11110011\n" }, { "input": "5 8 3\n00111\n10111001", "output": "10000\n11000010\n" }, { "input": "10 10 5\n1100110011\n1011001111", "output": "100010010001000\n100010000100100\n" }, { "input": "5 8 2\n10001\n10101001", "output": "10100\n10101100\n" }, { "input": "5 8 5\n00101\n01110011", "output": "10010\n10000000\n" }, { "input": "5 8 4\n10101\n10001000", "output": "10101\n10001000\n" }, { "input": "5 8 4\n00111\n10101101", "output": "1100\n10110010\n" }, { "input": "5 8 4\n00101\n10100000", "output": "101\n10100000\n" }, { "input": "10 10 6\n1101110011\n1111001101", "output": "1100000011001000\n1100000100100010\n" }, { "input": "5 8 4\n10101\n10000100", "output": "100001\n10010000\n" }, { "input": "5 8 4\n01101\n10000000", "output": "1101\n10000000\n" }, { "input": "5 8 3\n11101\n10110001", "output": "110000\n11000100\n" }, { "input": "10 10 4\n1000110011\n1011001101", "output": "10000010001000\n10000100100010\n" }, { "input": "5 8 2\n10101\n10101000", "output": "10101\n10101000\n" }, { "input": "5 8 4\n01100\n10100001", "output": "1100\n10100001\n" }, { "input": "2 3 1\n11\n111", "output": "110\n1010\n" }, { "input": "5 8 8\n00100\n11101001", "output": "100\n11101001\n" }, { "input": "5 8 4\n00111\n10101111", "output": "101000\n11010000\n" }, { "input": "10 10 6\n1101110011\n1111001100", "output": "1100000010110011\n1100000100001100\n" }, { "input": "5 8 1\n10101\n10000100", "output": "11001\n10001000\n" }, { "input": "5 8 6\n00100\n10110001", "output": "100\n10110001\n" }, { "input": "5 8 2\n10101\n00101000", "output": "10101\n101000\n" }, { "input": "5 8 4\n11100\n10100001", "output": "11100\n10100001\n" }, { "input": "5 8 8\n01100\n11101001", "output": "100100\n100000001\n" }, { "input": "5 8 4\n00110\n10101111", "output": "100000\n11001001\n" }, { "input": "5 8 2\n00001\n10100000", "output": "1\n10100000\n" }, { "input": "10 10 6\n1101110011\n0111001100", "output": "10010110011\n1100001100\n" }, { "input": "5 8 6\n11100\n10110001", "output": "101100\n11000001\n" }, { "input": "5 8 2\n00101\n00101000", "output": "101\n101000\n" }, { "input": "5 8 31\n00101\n00000001", "output": "1000\n100\n" }, { "input": "5 8 8\n01100\n01101001", "output": "100100\n10000001\n" }, { "input": "10 10 6\n1111110011\n0111001100", "output": "100010000110011\n100001000001100\n" }, { "input": "5 8 2\n00101\n00001000", "output": "101\n1000\n" }, { "input": "5 8 0\n10100\n10100000", "output": "10100\n10100000\n" }, { "input": "5 8 31\n00111\n00000001", "output": "1000\n10\n" } ]
0/::0
Takahashi and Aoki love calculating things, so they will play with numbers now. First, they came up with one positive integer each. Takahashi came up with X, and Aoki came up with Y. Then, they will enjoy themselves by repeating the following operation K times: * Compute the bitwise AND of the number currently kept by Takahashi and the number currently kept by Aoki. Let Z be the result. * Then, add Z to both of the numbers kept by Takahashi and Aoki. However, it turns out that even for the two math maniacs this is just too much work. Could you find the number that would be kept by Takahashi and the one that would be kept by Aoki eventually? Note that input and output are done in binary. Especially, X and Y are given as strings S and T of length N and M consisting of `0` and `1`, respectively, whose initial characters are guaranteed to be `1`. Constraints * 1 ≤ K ≤ 10^6 * 1 ≤ N,M ≤ 10^6 * The initial characters of S and T are `1`. Input Input is given from Standard Input in the following format: N M K S T Output In the first line, print the number that would be kept by Takahashi eventually; in the second line, print the number that would be kept by Aoki eventually. Those numbers should be represented in binary and printed as strings consisting of `0` and `1` that begin with `1`. Examples Input 2 3 3 11 101 Output 10000 10010 Input 5 8 3 10101 10101001 Output 100000 10110100 Input 10 10 10 1100110011 1011001101 Output 10000100000010001000 10000100000000100010
[ "\n", "def main():\n \n\n st = []\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n \n st = []\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n \n st = []\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n \n \n st = []\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n \n \n st = []\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n \n\n st = []\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n \n st = []\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n \n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n \n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n \n j = p\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n \n j += 1\n continue\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n \n \n j += 1\n continue\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n \n \n j += 1\n continue\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n \n \n j += 1\n continue\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n \n \n j += 1\n continue\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n t[j] ^= 1\n \n j += 1\n continue\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n t[j] ^= 1\n m.append(j)\n j += 1\n continue\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n t[j] ^= 1\n m.append(j)\n j += 1\n continue\n\n if s[j] != xs and t[j] != xt:\n if not z:\n s[j] = t[j] = 1\n break\n else:\n s[j] = t[j] = 0\n j += 1\n z -= 1\n xs = xt = 1\n continue\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n t[j] ^= 1\n m.append(j)\n j += 1\n continue\n\n if s[j] != xs and t[j] != xt:\n if not z:\n s[j] = t[j] = 1\n break\n else:\n s[j] = t[j] = 0\n j += 1\n z -= 1\n xs = xt = 1\n continue\n\n st += reversed(m)\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n t[j] ^= 1\n m.append(j)\n j += 1\n continue\n\n if s[j] != xs and t[j] != xt:\n if not z:\n s[j] = t[j] = 1\n break\n else:\n s[j] = t[j] = 0\n j += 1\n z -= 1\n xs = xt = 1\n continue\n\n st += reversed(m)\n\n elif s[i] or t[i]:\n st.append(i)\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n t[j] ^= 1\n m.append(j)\n j += 1\n continue\n\n if s[j] != xs and t[j] != xt:\n if not z:\n s[j] = t[j] = 1\n break\n else:\n s[j] = t[j] = 0\n j += 1\n z -= 1\n xs = xt = 1\n continue\n\n st += reversed(m)\n\n elif s[i] or t[i]:\n st.append(i)\n\n s = s[:len_max + 1]\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n t[j] ^= 1\n m.append(j)\n j += 1\n continue\n\n if s[j] != xs and t[j] != xt:\n if not z:\n s[j] = t[j] = 1\n break\n else:\n s[j] = t[j] = 0\n j += 1\n z -= 1\n xs = xt = 1\n continue\n\n st += reversed(m)\n\n elif s[i] or t[i]:\n st.append(i)\n\n s = s[:len_max + 1]\n t = t[:len_max + 1]\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n t[j] ^= 1\n m.append(j)\n j += 1\n continue\n\n if s[j] != xs and t[j] != xt:\n if not z:\n s[j] = t[j] = 1\n break\n else:\n s[j] = t[j] = 0\n j += 1\n z -= 1\n xs = xt = 1\n continue\n\n st += reversed(m)\n\n elif s[i] or t[i]:\n st.append(i)\n\n s = s[:len_max + 1]\n t = t[:len_max + 1]\n\n while not s[-1]:\n s.pop()\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n t[j] ^= 1\n m.append(j)\n j += 1\n continue\n\n if s[j] != xs and t[j] != xt:\n if not z:\n s[j] = t[j] = 1\n break\n else:\n s[j] = t[j] = 0\n j += 1\n z -= 1\n xs = xt = 1\n continue\n\n st += reversed(m)\n\n elif s[i] or t[i]:\n st.append(i)\n\n s = s[:len_max + 1]\n t = t[:len_max + 1]\n\n while not s[-1]:\n s.pop()\n while not t[-1]:\n t.pop()\n\n \nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n t[j] ^= 1\n m.append(j)\n j += 1\n continue\n\n if s[j] != xs and t[j] != xt:\n if not z:\n s[j] = t[j] = 1\n break\n else:\n s[j] = t[j] = 0\n j += 1\n z -= 1\n xs = xt = 1\n continue\n\n st += reversed(m)\n\n elif s[i] or t[i]:\n st.append(i)\n\n s = s[:len_max + 1]\n t = t[:len_max + 1]\n\n while not s[-1]:\n s.pop()\n while not t[-1]:\n t.pop()\n\n print(*reversed(s), sep='')\n \n\nmain()\n", "def main():\n N, M, K = map(int, input().split())\n\n MAX_N = 2000000\n\n s = [0] * MAX_N\n t = [0] * MAX_N\n for i, c in zip(range(N - 1, -1, -1), input()):\n s[i] = int(c)\n for i, c in zip(range(M - 1, -1, -1), input()):\n t[i] = int(c)\n\n len_max = max(N, M) - 1\n st = []\n for i in range(len_max, -1, -1):\n m = []\n if s[i] and t[i]:\n s[i] = t[i] = 0\n xs = xt = 1\n z = K - 1\n j = i + 1\n\n while xs or xt:\n if not s[j] and not t[j]:\n if xs and not xt:\n s[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n elif not xs and xt:\n t[j] = 1\n st.append(j)\n len_max = max(len_max, j)\n break\n\n if not st or st[-1] - j > z:\n s[j + z] = t[j + z] = 1\n len_max = max(len_max, j + z)\n break\n\n p = st.pop()\n z -= p - j\n j = p\n\n if s[j] == xs and t[j] == xt:\n s[j] = t[j] = 0\n j += 1\n continue\n\n if xs and xt:\n xs = s[j]\n xt = t[j]\n s[j] ^= 1\n t[j] ^= 1\n m.append(j)\n j += 1\n continue\n\n if s[j] != xs and t[j] != xt:\n if not z:\n s[j] = t[j] = 1\n break\n else:\n s[j] = t[j] = 0\n j += 1\n z -= 1\n xs = xt = 1\n continue\n\n st += reversed(m)\n\n elif s[i] or t[i]:\n st.append(i)\n\n s = s[:len_max + 1]\n t = t[:len_max + 1]\n\n while not s[-1]:\n s.pop()\n while not t[-1]:\n t.pop()\n\n print(*reversed(s), sep='')\n print(*reversed(t), sep='')\n\n\nmain()\n" ]
33
[ { "input": "2 3 3\n11\n101", "output": "10000\n10010" }, { "input": "10 10 10\n1100110011\n1011001101", "output": "10000100000010001000\n10000100000000100010" }, { "input": "5 8 3\n10101\n10101001", "output": "100000\n10110100" } ]
[ { "input": "5 8 3\n00101\n10101001", "output": "10000\n10110100\n" }, { "input": "5 8 3\n00101\n10100001", "output": "1000\n10100100\n" }, { "input": "5 8 5\n00101\n10110001", "output": "1000\n10110100\n" }, { "input": "5 8 5\n00101\n10110011", "output": "10010\n11000000\n" }, { "input": "5 8 3\n10101\n10100001", "output": "11000\n10100100\n" }, { "input": "5 8 3\n00100\n10101001", "output": "100\n10101001\n" }, { "input": "5 8 5\n00101\n10000001", "output": "1000\n10000100\n" }, { "input": "5 8 5\n10101\n10110001", "output": "101000\n11000100\n" }, { "input": "10 10 14\n1100110011\n1011001101", "output": "100001000000000010001000\n100001000000000000100010\n" }, { "input": "5 8 3\n10101\n10111001", "output": "110000\n11010100\n" }, { "input": "5 8 2\n00101\n10101001", "output": "1000\n10101100\n" }, { "input": "5 8 5\n00001\n10110011", "output": "10\n10110100\n" }, { "input": "5 8 3\n01100\n10101001", "output": "100100\n11000001\n" }, { "input": "5 8 5\n10101\n00110001", "output": "101000\n1000100\n" }, { "input": "10 10 14\n1110110011\n1011001101", "output": "100001000000000100001000\n100001000000000000100010\n" }, { "input": "5 8 5\n00001\n10110111", "output": "10\n10111000\n" }, { "input": "5 8 5\n00101\n00110001", "output": "1000\n110100\n" }, { "input": "5 8 5\n00111\n00110001", "output": "1000\n110010\n" }, { "input": "5 8 5\n00111\n00100001", "output": "1000\n100010\n" }, { "input": "5 8 5\n10111\n00100001", "output": "11000\n100010\n" }, { "input": "2 3 2\n11\n101", "output": "1000\n1010\n" }, { "input": "5 8 3\n10101\n10001001", "output": "100000\n10010100\n" }, { "input": "5 8 3\n00001\n10101001", "output": "1000\n10110000\n" }, { "input": "5 8 5\n00100\n10100001", "output": "100\n10100001\n" }, { "input": "5 8 5\n00100\n10110011", "output": "100\n10110011\n" }, { "input": "5 8 3\n00111\n10101001", "output": "100000\n11000010\n" }, { "input": "5 8 5\n00111\n10000001", "output": "1000\n10000010\n" }, { "input": "10 10 5\n1100110011\n1011001101", "output": "100001010001000\n100001000100010\n" }, { "input": "5 8 3\n10101\n10111000", "output": "100101\n11001000\n" }, { "input": "5 8 2\n10101\n10101001", "output": "11000\n10101100\n" }, { "input": "10 10 3\n1110110011\n1011001101", "output": "1001001001000\n1000101100010\n" }, { "input": "5 8 5\n00101\n00110011", "output": "10010\n1000000\n" }, { "input": "5 8 5\n11111\n00100001", "output": "1000000000\n1000000010\n" }, { "input": "5 8 3\n00011\n10101001", "output": "100\n10101010\n" }, { "input": "5 8 5\n00100\n10110010", "output": "100\n10110010\n" }, { "input": "5 8 5\n00011\n10000001", "output": "100\n10000010\n" }, { "input": "10 10 5\n1101110011\n1011001101", "output": "101000011001000\n101000000100010\n" }, { "input": "5 8 5\n11111\n00110001", "output": "110000\n1000010\n" }, { "input": "5 8 4\n00101\n10001001", "output": "100000\n10100100\n" }, { "input": "5 8 4\n00101\n10000000", "output": "101\n10000000\n" }, { "input": "5 8 8\n10100\n10100001", "output": "10100\n10100001\n" }, { "input": "5 8 5\n10011\n10000001", "output": "10100\n10000010\n" }, { "input": "10 10 5\n1101110011\n1111001101", "output": "110000011001000\n110000100100010\n" }, { "input": "5 8 5\n11111\n01110001", "output": "110000\n10000010\n" }, { "input": "5 8 4\n00100\n10001001", "output": "100\n10001001\n" }, { "input": "5 8 4\n10101\n10000000", "output": "10101\n10000000\n" }, { "input": "10 10 1\n1101110011\n1111001101", "output": "11010110100\n11100001110\n" }, { "input": "5 8 4\n10101\n10000001", "output": "11000\n10000100\n" }, { "input": "5 8 5\n11111\n01100001", "output": "1000000\n10000010\n" }, { "input": "5 8 8\n00110\n10110011", "output": "1000\n10110101\n" }, { "input": "5 8 4\n11101\n10000001", "output": "100000\n10000100\n" }, { "input": "5 8 4\n01101\n10000001", "output": "10000\n10000100\n" }, { "input": "5 8 9\n11111\n01100011", "output": "1000100\n10001000\n" }, { "input": "5 8 9\n01111\n01100011", "output": "10100\n1101000\n" }, { "input": "2 3 3\n11\n001", "output": "100\n10\n" }, { "input": "5 8 5\n00101\n10100011", "output": "100010\n11000000\n" }, { "input": "5 8 1\n00101\n10110011", "output": "110\n10110100\n" }, { "input": "5 8 3\n10100\n10101001", "output": "10100\n10101001\n" }, { "input": "5 8 5\n00100\n10000001", "output": "100\n10000001\n" }, { "input": "10 10 4\n1100110011\n1011001101", "output": "10000110001000\n10000100100010\n" }, { "input": "5 8 2\n00101\n10101000", "output": "101\n10101000\n" }, { "input": "5 8 3\n01100\n00101001", "output": "100100\n1000001\n" }, { "input": "10 10 14\n1110010011\n1011001101", "output": "100000000000001001001000\n100000000000000110000010\n" }, { "input": "5 8 5\n10001\n10110111", "output": "100010\n11001000\n" }, { "input": "2 3 2\n11\n111", "output": "1000\n1100\n" }, { "input": "5 8 5\n00100\n11110011", "output": "100\n11110011\n" }, { "input": "5 8 3\n00111\n10111001", "output": "10000\n11000010\n" }, { "input": "10 10 5\n1100110011\n1011001111", "output": "100010010001000\n100010000100100\n" }, { "input": "5 8 2\n10001\n10101001", "output": "10100\n10101100\n" }, { "input": "5 8 5\n00101\n01110011", "output": "10010\n10000000\n" }, { "input": "5 8 4\n10101\n10001000", "output": "10101\n10001000\n" }, { "input": "5 8 4\n00111\n10101101", "output": "1100\n10110010\n" }, { "input": "5 8 4\n00101\n10100000", "output": "101\n10100000\n" }, { "input": "10 10 6\n1101110011\n1111001101", "output": "1100000011001000\n1100000100100010\n" }, { "input": "5 8 4\n10101\n10000100", "output": "100001\n10010000\n" }, { "input": "5 8 4\n01101\n10000000", "output": "1101\n10000000\n" }, { "input": "5 8 3\n11101\n10110001", "output": "110000\n11000100\n" }, { "input": "10 10 4\n1000110011\n1011001101", "output": "10000010001000\n10000100100010\n" }, { "input": "5 8 2\n10101\n10101000", "output": "10101\n10101000\n" }, { "input": "5 8 4\n01100\n10100001", "output": "1100\n10100001\n" }, { "input": "2 3 1\n11\n111", "output": "110\n1010\n" }, { "input": "5 8 8\n00100\n11101001", "output": "100\n11101001\n" }, { "input": "5 8 4\n00111\n10101111", "output": "101000\n11010000\n" }, { "input": "10 10 6\n1101110011\n1111001100", "output": "1100000010110011\n1100000100001100\n" }, { "input": "5 8 1\n10101\n10000100", "output": "11001\n10001000\n" }, { "input": "5 8 6\n00100\n10110001", "output": "100\n10110001\n" }, { "input": "5 8 2\n10101\n00101000", "output": "10101\n101000\n" }, { "input": "5 8 4\n11100\n10100001", "output": "11100\n10100001\n" }, { "input": "5 8 8\n01100\n11101001", "output": "100100\n100000001\n" }, { "input": "5 8 4\n00110\n10101111", "output": "100000\n11001001\n" }, { "input": "5 8 2\n00001\n10100000", "output": "1\n10100000\n" }, { "input": "10 10 6\n1101110011\n0111001100", "output": "10010110011\n1100001100\n" }, { "input": "5 8 6\n11100\n10110001", "output": "101100\n11000001\n" }, { "input": "5 8 2\n00101\n00101000", "output": "101\n101000\n" }, { "input": "5 8 31\n00101\n00000001", "output": "1000\n100\n" }, { "input": "5 8 8\n01100\n01101001", "output": "100100\n10000001\n" }, { "input": "10 10 6\n1111110011\n0111001100", "output": "100010000110011\n100001000001100\n" }, { "input": "5 8 2\n00101\n00001000", "output": "101\n1000\n" }, { "input": "5 8 0\n10100\n10100000", "output": "10100\n10100000\n" }, { "input": "5 8 31\n00111\n00000001", "output": "1000\n10\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A,B=map(int,input().split())\n", "A,B=map(int,input().split())\nb=A%3==0 or B%3==0 or (A+B)%3==0\n", "A,B=map(int,input().split())\nb=A%3==0 or B%3==0 or (A+B)%3==0\nprint(\"Possible\" if b else \"Impossible\")\n" ]
4
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A, B = map(int, input().split())\n", "A, B = map(int, input().split())\n\nif A%3!=0 and B%3!=0 and (A+B)%3!=0:print('Impossible')\n", "A, B = map(int, input().split())\n\nif A%3!=0 and B%3!=0 and (A+B)%3!=0:print('Impossible')\nelse:print('Possible')\n" ]
4
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b=map(int,input().split())\n", "a,b=map(int,input().split())\nans='Impossible'\n", "a,b=map(int,input().split())\nans='Impossible'\np='Possible'\n", "a,b=map(int,input().split())\nans='Impossible'\np='Possible'\nif a%3==0 or b%3==0 or (a+b)%3==0:\n ans=p\n", "a,b=map(int,input().split())\nans='Impossible'\np='Possible'\nif a%3==0 or b%3==0 or (a+b)%3==0:\n ans=p\nprint(ans)\n" ]
6
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b=map(int,input().split())\n", "a,b=map(int,input().split())\nprint([\"Impossible\",\"Possible\"][(a%3==0)or(b%3==0)or((a+b)%3==0)])\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b = map(int,input().split())\n", "a,b = map(int,input().split())\nprint([\"Impossible\", \"Possible\"][a*b%3==0 or (a+b)%3==0])\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A, B = map(int, input().split())\n", "A, B = map(int, input().split())\nprint('Possible' if (A*B%3==0) or ((A+B)%3==0) else 'Impossible')\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b=map(int,input().split())\nc=a+b\n", "a,b=map(int,input().split())\nc=a+b\nif a*b*c % 3 == 0:\n print('Possible')\n", "a,b=map(int,input().split())\nc=a+b\nif a*b*c % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')\n" ]
4
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b=map(int,input().split())\n", "a,b=map(int,input().split())\nprint(\"Possible\" if any([x % 3 == 0 for x in [a,b,a+b]]) else \"Impossible\")\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b=map(int,input().split());\n", "a,b=map(int,input().split());print([\"Imp\",\"P\"][any([(a+b)%3==0,a%3==0,b%3==0])]+\"ossible\")\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b=map(int,input().split())\n", "a,b=map(int,input().split())\nprint('Possible' if (a%3==0 or b%3==0 or (a+b)%3==0) else 'Impossible')\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a, b=map(int, input().split())\n", "a, b=map(int, input().split())\nprint('Possible' if (a%3 == 0) or (b%3 == 0) or ((a+b)%3 ==0) else 'Impossible')\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A,B=map(int,input().split())\n", "A,B=map(int,input().split())\n\nprint(\"Possible\" if (A*B*(A+B)%3)==0 else \"Impossible\")\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A,B=map(int,input().split())\n", "A,B=map(int,input().split())\nprint(['P','Imp'][(A+B)%3*(A%3)*(B%3)>0]+'ossible')\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b = map(int,input().split())\n", "a,b = map(int,input().split())\nprint(\"Possible\" if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0 else \"Impossible\")\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A,B = map(int,input().split())\n", "A,B = map(int,input().split())\nif (A+B)%3==0 or A%3==0 or B%3==0:\n print(\"Possible\")\n", "A,B = map(int,input().split())\nif (A+B)%3==0 or A%3==0 or B%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n" ]
4
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "N, K = map(int, input().split())\n", "N, K = map(int, input().split())\nprint(\"Possible\" if N*K*(N+K)%3==0 else \"Impossible\")\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A,B=map(int,input().split());\n", "A,B=map(int,input().split());print(['Impossible','Possible'][any([True for i in [A,B,A+B] if i%3==0])])\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b=map(int,input().split())\n", "a,b=map(int,input().split())\nans=[a%3,b%3,(a+b)%3]\n", "a,b=map(int,input().split())\nans=[a%3,b%3,(a+b)%3]\nif 0 in ans:\n print(\"Possible\")\n", "a,b=map(int,input().split())\nans=[a%3,b%3,(a+b)%3]\nif 0 in ans:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n" ]
5
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b=map(int,input().split())\n", "a,b=map(int,input().split())\nprint('Possible' if a*b%3==0 or (a+b)%3==0 else 'Impossible')\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A,B=map(int,input().split())\n", "A,B=map(int,input().split())\nprint(['Imp','P'][A%3==0 or B%3==0 or (A+B)%3==0]+'ossible')\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A,B=map(int, input().split())\n", "A,B=map(int, input().split())\nprint(\"Possible\" if A%3==0 or B%3==0 or (A+B)%3==0 else \"Impossible\")\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b = [int(x) for x in input().split()]\n", "a,b = [int(x) for x in input().split()]\nprint('Possible' if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0 else 'Impossible')\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A,B=map(int,input().split());\n", "A,B=map(int,input().split());print((\"Possible\",\"Impossible\")[min([A%3,B%3,(A+B)%3])])\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b=map(int,input().split());\n", "a,b=map(int,input().split());print(('Imp'*((a%3 and b%3 and(a+b)%3)>0)or'P')+'ossible')\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A, B = map(int,input().split())\n", "A, B = map(int,input().split())\nprint('Possible' if 0 in [(A+B)%3, A%3, B%3] else 'Impossible')\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A,B=map(int,input().split())\n", "A,B=map(int,input().split())\nprint(\"Possible\" if (A+B)%3==0 or (A*B)%3==0 else \"Impossible\")\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b=map(int,input().split());\n", "a,b=map(int,input().split());print('PIomspsoisbslieb l e'[list(map(lambda x:x%3,[a,b,a+b])).count(0)==0::2])\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "print([\"P\",\"Imp\"][eval(input().replace(\" \",\"*\"))%3%2]+\"ossible\")\n" ]
2
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a, b = map(int, input().split())\n", "a, b = map(int, input().split())\nprint('Impossible' if a*b*(a+b) % 3 else 'Possible')\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "a,b=map(int,input().split())\n", "a,b=map(int,input().split())\nprint(\"Possible\" if (a%3==0 or b%3==0 or (a+b)%3==0) else \"Impossible\")\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]
0/::0
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies. Constraints * 1 \leq A,B \leq 100 * Both A and B are integers. Input Input is given from Standard Input in the following format: A B Output If it is possible to give cookies so that each of the three goats can have the same number of cookies, print `Possible`; otherwise, print `Impossible`. Examples Input 4 5 Output Possible Input 1 1 Output Impossible
[ "\n", "A,B=map(int,input().split());\n", "A,B=map(int,input().split());print(['Imp','P'][any([1 for i in [A,B,A+B] if i%3==0])]+'ossible')\n" ]
3
[ { "input": "4 5", "output": "Possible" }, { "input": "1 1", "output": "Impossible" } ]
[ { "input": "4 0", "output": "Possible\n" }, { "input": "-1 2", "output": "Impossible\n" }, { "input": "1 2", "output": "Possible\n" }, { "input": "7 0", "output": "Possible\n" }, { "input": "0 2", "output": "Possible\n" }, { "input": "7 -1", "output": "Possible\n" }, { "input": "7 -2", "output": "Impossible\n" }, { "input": "-1 4", "output": "Possible\n" }, { "input": "7 -4", "output": "Possible\n" }, { "input": "-1 8", "output": "Impossible\n" }, { "input": "5 -4", "output": "Impossible\n" }, { "input": "-1 14", "output": "Impossible\n" }, { "input": "8 -4", "output": "Impossible\n" }, { "input": "-1 28", "output": "Possible\n" }, { "input": "5 0", "output": "Possible\n" }, { "input": "-2 28", "output": "Impossible\n" }, { "input": "5 -1", "output": "Impossible\n" }, { "input": "-2 40", "output": "Impossible\n" }, { "input": "0 -1", "output": "Possible\n" }, { "input": "-3 40", "output": "Possible\n" }, { "input": "-1 -1", "output": "Impossible\n" }, { "input": "-3 57", "output": "Possible\n" }, { "input": "-1 -2", "output": "Possible\n" }, { "input": "-2 57", "output": "Possible\n" }, { "input": "-2 -2", "output": "Impossible\n" }, { "input": "-2 81", "output": "Possible\n" }, { "input": "0 -2", "output": "Possible\n" }, { "input": "-2 29", "output": "Possible\n" }, { "input": "-2 0", "output": "Possible\n" }, { "input": "-3 29", "output": "Possible\n" }, { "input": "-2 1", "output": "Impossible\n" }, { "input": "-3 4", "output": "Possible\n" }, { "input": "-1 1", "output": "Possible\n" }, { "input": "-5 4", "output": "Impossible\n" }, { "input": "0 8", "output": "Possible\n" }, { "input": "-8 4", "output": "Impossible\n" }, { "input": "0 6", "output": "Possible\n" }, { "input": "-13 4", "output": "Possible\n" }, { "input": "-1 6", "output": "Possible\n" }, { "input": "-13 0", "output": "Possible\n" }, { "input": "-1 7", "output": "Possible\n" }, { "input": "-1 0", "output": "Possible\n" }, { "input": "-2 2", "output": "Possible\n" }, { "input": "0 0", "output": "Possible\n" }, { "input": "1 0", "output": "Possible\n" }, { "input": "2 0", "output": "Possible\n" }, { "input": "1 3", "output": "Possible\n" }, { "input": "2 -1", "output": "Impossible\n" }, { "input": "2 2", "output": "Impossible\n" }, { "input": "2 -2", "output": "Possible\n" }, { "input": "2 3", "output": "Possible\n" }, { "input": "3 -2", "output": "Possible\n" }, { "input": "2 6", "output": "Possible\n" }, { "input": "4 -2", "output": "Impossible\n" }, { "input": "2 9", "output": "Possible\n" }, { "input": "1 -2", "output": "Impossible\n" }, { "input": "4 9", "output": "Possible\n" }, { "input": "1 -4", "output": "Possible\n" }, { "input": "2 14", "output": "Impossible\n" }, { "input": "1 -3", "output": "Possible\n" }, { "input": "2 17", "output": "Impossible\n" }, { "input": "1 -1", "output": "Possible\n" }, { "input": "2 1", "output": "Possible\n" }, { "input": "4 1", "output": "Impossible\n" }, { "input": "4 2", "output": "Possible\n" }, { "input": "3 1", "output": "Possible\n" }, { "input": "7 2", "output": "Possible\n" }, { "input": "4 -1", "output": "Possible\n" }, { "input": "7 1", "output": "Impossible\n" }, { "input": "6 -1", "output": "Possible\n" }, { "input": "6 1", "output": "Possible\n" }, { "input": "6 -2", "output": "Possible\n" }, { "input": "6 0", "output": "Possible\n" }, { "input": "9 -2", "output": "Possible\n" }, { "input": "-2 -1", "output": "Possible\n" }, { "input": "9 -1", "output": "Possible\n" }, { "input": "-3 -2", "output": "Possible\n" }, { "input": "11 -1", "output": "Impossible\n" }, { "input": "-1 -4", "output": "Impossible\n" }, { "input": "12 -1", "output": "Possible\n" }, { "input": "-1 -6", "output": "Possible\n" }, { "input": "23 -1", "output": "Impossible\n" }, { "input": "-2 -6", "output": "Possible\n" }, { "input": "23 0", "output": "Possible\n" }, { "input": "-4 -6", "output": "Possible\n" }, { "input": "23 -2", "output": "Possible\n" }, { "input": "-4 -10", "output": "Impossible\n" }, { "input": "15 -2", "output": "Possible\n" }, { "input": "-4 -18", "output": "Possible\n" }, { "input": "15 -3", "output": "Possible\n" }, { "input": "-5 -18", "output": "Possible\n" }, { "input": "0 -3", "output": "Possible\n" }, { "input": "-5 -6", "output": "Possible\n" }, { "input": "1 -6", "output": "Possible\n" }, { "input": "0 -6", "output": "Possible\n" }, { "input": "0 -4", "output": "Possible\n" }, { "input": "0 -11", "output": "Possible\n" }, { "input": "2 -4", "output": "Impossible\n" }, { "input": "0 -17", "output": "Possible\n" }, { "input": "-1 -5", "output": "Possible\n" } ]