import sys P,Q,x,y = input().split() rQ = Q[::-1] ry = y[::-1] x = int(x) P = int(P) rry = int(ry) inv = pow(rry,P-2,P) rrQ = int(rQ) u = inv * (x-rrQ) % P s = len(Q) + 1 now = pow(10,s,P) while now % P != u: s += 1 now = now * 10 % P ans = str(ry) + '0' * (s-len(Q)) + str(rQ) if rry % P != 0: print(ans) exit() inv = pow(rrQ,P-2,P) u = inv * (x-1) % P s = 1 now = 10 while now != u: s += 1 now = now * 10 % P ans = str(ry) + str(rQ) + '0' * (s-1) + '1' print(ans)