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) print(ans)