import strutils, sequtils, math let XY = stdin.readLine.split.map parseInt (X, Y) = (XY[0], XY[1]) var Arr, Brr = newSeq[tuple[x, y: int]]() Arr.add (0, 0) for x_abs in 1 .. 2: let y_abs = 3 - x_abs for x_sgn in countup(-1, 1, 2): for y_sgn in countup(-1, 1, 2): Arr.add (x_sgn * x_abs, y_sgn * y_abs) proc fn(n: int): tuple[x, y: int] = var v = n while v != 0: result.x += Arr[v mod Arr.len].x result.y += Arr[v mod Arr.len].y v = v div Arr.len for i in 0 ..< Arr.len ^ 3: Brr.add i.fn if (X, Y) in Brr: echo "YES" else: echo "NO"