x, k, d = list(map(int, input().split()))

x = abs(x)

div, mod = divmod(x, d)

c = div - k

if c == 0:

    ans = mod

elif c > 0:

    ans = x - d * k

else:

    if c%2 == 1: ans = d - mod

    else: ans = mod

print(ans)
x, k, d = list(map(int, input().split()))

x = abs(x)

div, mod = divmod(x, d)

c = k - div

if c <= 0:

    ans = x - d * k

else:

    if c%2 == 1: ans = d - mod

    else: ans = mod

print(ans)
x, k, d = list(map(int, input().split()))
x = abs(x)
div, mod = divmod(x, d)
c = div - k
if c == 0:
    ans = mod
elif c > 0:
    ans = x - d * k
else:
    if c % 2 == 1:
        ans = d - mod
    else:
        ans = mod
print(ans)

x, k, d = list(map(int, input().split()))
x = abs(x)
div, mod = divmod(x, d)
c = k - div
if c <= 0:
    ans = x - d * k
else:
    if c % 2 == 1:
        ans = d - mod
    else:
        ans = mod
print(ans)

-c = div - k -if c == 0: -    ans = mod -elif c > 0: +c = k - div +if c <= 0: