import times, strutils, sequtils, math, algorithm, tables, sets, lists, intsets import critbits, future, strformat, deques,heapqueue template `max=`(x,y) = x = max(x,y) template `min=`(x,y) = x = min(x,y) template `mod=`(x,y) = x = x mod y template scan2 = (scan(), scan()) template scan3 = (scan(), scan()) let read* = iterator: string {.closure.} = while true: (for s in stdin.readLine.split: yield s) proc scan(): int = read().parseInt proc scanf(): float = read().parseFloat proc toInt(c:char): int = return int(c) - int('0') proc getAns(v:seq[int])= var t = v a0:int a1:int t.sort() echo t.join(" ") (a0,a1) = (scan(),scan()) if a0 == 4: quit() while t.nextPermutation: echo t.join(" ") (a0,a1) = (scan(),scan()) if a0 == 4: quit() #return t proc solve()= var lower = [0,1,2,3,4] upper = [5,6,7,8,9] lowerMax = 0 lowerMaxSeq:seq[int] upperMax = 0 upperMaxSeq:seq[int] a0:int a1:int for i in 0..<4: var t = lower[0.. lowerMax: lowerMax = a0+a1 lowerMaxSeq = t for i in 0..<4: var t = upper[0.. upperMax: upperMax = a0+a1 upperMaxSeq = t if (lowerMax,upperMax) == (4,0): lowerMaxSeq.getAns elif (lowerMax,upperMax) == (0,4): upperMaxSeq.getAns elif (lowerMax,upperMax) == (3,1): for i in 0..<4: for j in 0..<4: var t = lowerMaxSeq[0..