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

x = abs(y)

i = int(x / d)

if i >= k:

    p = x - k * d

elif i == x / d:

    if (i + k) % 2 == 0:

        p = 0

    else:

        p = d

else:

    if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0):

        p = x - i * d

    else:

        p = (i + 1) * d - x

print((int(p)))
y, k, d = list(map(int, input().split()))

x = abs(y)

if k * d <= x:

    a = x - k * d

else:

    if x % d == 0:

        if (k - (x / d)) % 2 == 0:

            a = 0

        else:

            a = d

    else:

        b = x // d

        if (k - b) % 2 == 0:

            a = x - d * b

        else:

            a = -x + b * d + d

print(a)
y, k, d = list(map(int, input().split()))
x = abs(y)
i = int(x / d)
if i >= k:
    p = x - k * d
elif i == x / d:
    if (i + k) % 2 == 0:
        p = 0
    else:
        p = d
else:
    if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0):
        p = x - i * d
    else:
        p = (i + 1) * d - x
print((int(p)))

y, k, d = list(map(int, input().split()))
x = abs(y)
if k * d <= x:
    a = x - k * d
else:
    if x % d == 0:
        if (k - (x / d)) % 2 == 0:
            a = 0
        else:
            a = d
    else:
        b = x // d
        if (k - b) % 2 == 0:
            a = x - d * b
        else:
            a = -x + b * d + d
print(a)

-i = int(x / d) -if i >= k: -    p = x - k * d -elif i == x / d: -    if (i + k) % 2 == 0: -        p = 0 +if k * d <= x: +    a = x - k * d +else: +    if x % d == 0: +        if (k - (x / d)) % 2 == 0: +            a = 0 +        else: +            a = d -        p = d -else: -    if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0): -        p = x - i * d -    else: -        p = (i + 1) * d - x -print((int(p))) +        b = x // d +        if (k - b) % 2 == 0: +            a = x - d * b +        else: +            a = -x + b * d + d +print(a)