# 前半の作戦はこれまでと同じ # まずM**N (mod B) = Rをpowで計算する # xi**2 (mod B)は常に0 for xi=B, or 1 for xi=1にできる # x1からR以下一番近いところにx1**2 (mod B)がなる値にx1を固定 # 同様にx2を決める # testerの4平方定理defを後半4つに使う import math def f(L): # Lを4平方和で表す O(L^1.5) for a in range(L+1): if 4*a*a > L: break for b in range(a, L+1): if a*a + 3*b*b > L: break for c in range(b, L+1): if a*a + b*b + 2*c*c > L: break dd = L - a*a - b*b - c*c d = math.isqrt(dd) if d*d == dd: return (a, b, c, d) N, M, B = map(int, input().split()) R = pow(M, N, B) R_remainder = R INF = 10**20 X = [] for i in range(2): #print('i', i, 'R_remainder', R_remainder, X) if R_remainder == 0: X.append(B) continue diff = INF visited = set() for j in range(1, B+1): calc = (j**2)%B if calc not in visited: visited.add(calc) if calc <= R_remainder and R_remainder-calc < diff: diff = R_remainder-calc num = j elif calc in visited: break X.append(num) R_remainder -= (num**2)%B if R_remainder == 0: for i in range(4): X.append(B) print('YES') print(*X) else: X2 = f(R_remainder) X.extend(X2) print('YES') print(*X)