import sys input = sys.stdin.readline P,Q,x,y=map(int,input().split()) # N mod P = x for tests in range(10**5): N=y+tests*Q REV=int(str(N)[::-1]) kk=pow(REV,P-2,P)*x%P # 10**y == kk # modが素数の場合 import math a = 10 b = kk mod = P SQ = int(math.sqrt(mod))+1 Powdict = {pow(a,i,mod):i for i in range(SQ)} # Baby-Step A = pow(pow(a,mod-2,mod),SQ,mod) for i in range(SQ): # Giant-Step if b*pow(A,i,mod)%mod in Powdict: ANS = i*SQ+Powdict[b*pow(A,i,mod)%mod] break else: continue XX=str(REV)+"0"*ANS if len(XX)<10000: print(XX) break