﻿namespace _01._3_6_9
{
    using System;
    using System.Globalization;
    using System.Threading;

    class ThreeSixNine
    {
        static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            long a = long.Parse(Console.ReadLine());
            long secretB = long.Parse(Console.ReadLine());
            long c = long.Parse(Console.ReadLine());

            long result = 0;
            long dividedResult;

            if (secretB == 3)
            {
                result = a + c;
            }
            else if (secretB == 6)
            {
                result = a * c;
            }
            else if (secretB == 9)
            {
                result = a % c;
            }

            if (result % 3 == 0)
            {
                dividedResult = result / 3;
            }
            else
            {
                dividedResult = result % 3;
            }

            Console.WriteLine(dividedResult);
            Console.WriteLine(result);
        }
    }
}
