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