P, Q, x, y = map(int, input().split()) P = 90007 N = int(str(y)[::-1]) print(N, end="") N %= P while N != x: print("0", end="") N *= 10 N %= P print()