def check(target): cnt = target//A + target//B - target//(A*B//g) if cnt1: if check(mid): high = mid else: low = mid mid = (low+high)//2 ans = high print(ans)