using System.Text;

namespace consap1
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] data = new int[n, 5];
            int ot = 0;
            StringBuilder sb = new StringBuilder();
            String[] inp;
            for (int i = 0; i < n; i++)
            {
                inp = Console.ReadLine().Split();
                for (int j = 0; j < 5; j++)
                    data[i, j] = int.Parse(inp[j]);
            }
            bool chek = true;
            for (int i = 0; i < n; i++)
            {
                chek = true;
                for (int j = 0; j < n - 1; j++)
                    if (j != i)
                    {
                        for (int k = j + 1; k < n; k++)
                            if (k != j && k != i)
                            {
                                if ((data[j, 0] - data[i, 0]) * (data[k, 0] - data[i, 0]) + (data[j, 1] - data[i, 1]) * (data[k, 1] - data[i, 1]) + (data[j, 2] - data[i, 2]) * (data[k, 2] - data[i, 2]) + (data[j, 3] - data[i, 3]) * (data[k, 3] - data[i, 3]) + (data[j, 4] - data[i, 4]) * (data[k, 4] - data[i, 4]) > 0)
                                {
                                    chek = false;
                                    j = n;
                                    break;
                                }
                            }
                    }
                if(chek)
                {
                    sb.AppendLine((i+1).ToString());
                    ot++;
                }
            }
            Console.WriteLine(ot);
            Console.WriteLine(sb);
        }
    }
}


using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            string input = Console.ReadLine();
            int pribors = int.Parse(data[0]);
            int guests = int.Parse(data[1]);
            var kinds = Array.ConvertAll(input.Split(' '), int.Parse);

            Dictionary<int, int> kind_count = new Dictionary<int, int>();
            foreach(var p in kinds)
            {
                if (kind_count.ContainsKey(p))
                    kind_count[p] = kind_count[p] + 1;
                else
                    kind_count.Add(p, 1);
            }

            double max = 0;
            int sum = 0;
            foreach (var m in kind_count.Values)
            {
                if (m > max)
                    max = m;
                sum += m;
            }

            blud = max / guests;
            int blud = (int)Math.Ceiling(max);

            int allpribors = kind_count.Count * blud * guests;

            Console.WriteLine(allpribors-sum);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Codeforces
{
    class B
    {
        private static int V(char ch)
        {
            if (ch - '0' >= 0 && ch - '0' <= 9) return ch - '0';
            return ch - 'A' + 10;
        }

        private static int Convert(string s, int rad)
        {
            int v = 0;
            int m = 1;
            for (int i = s.Length - 1; i >=0 ; i--)
            {
                if (V(s[i]) >= rad) return -1;
                v += m * V(s[i]);
                m *= rad;
            }

            return v;
        }

        private static object Go()
        {
            string[] data = GetString().Split(':');
            string h = data[0];
            string m = data[1];

            List<int> sol = new List<int>();
            for (int rad = 2; rad < 61; rad++)
            {
                int hi = Convert(h, rad);
                int mi = Convert(m, rad);

                if (hi > -1 && mi > -1 && hi < 24 && mi < 60)
                {
                    sol.Add(rad);
                    if (rad == 60)
                    {
                        return -1;
                    }
                }
            }

            if (sol.Count == 0) return 0;

            return string.Join(" ", sol);
        }

        #region Template

        public static void Main(string[] args)
        {
            object output = Go();
            if (output != null)
                Wl<string>(output.ToString());
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            while (ioEnum == null || !ioEnum.MoveNext())
            {
                ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
            }

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static void Wl<T>(T o)
        {
            Console.WriteLine(o.ToString());
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            Wl(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        public struct Tuple<T, K>
        {
            public T Item1;
            public K Item2;

            public Tuple(T t, K k)
            {
                Item1 = t;
                Item2 = k;
            }

            public override bool Equals(object obj)
            {
                var o = (Tuple<T, K>)obj;
                return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);
            }

            public override int GetHashCode()
            {
                return Item1.GetHashCode() ^ Item2.GetHashCode();
            }

            public override string ToString()
            {
                return "(" + Item1 + " " + Item2 + ")";
            }
        }

        #endregion
    }
}


#include <iostream>
#include <string>;
#include <algorithm>;
#include <math.h>;
#include <vector>;
#include <map>;
#include <set>;

#define ll long long;
#define ull unsigned long long;
using namespace std;

string m[500000];
unsigned long long gcd(unsigned long long a, unsigned long long b)
{

	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}
int main()
{

	unsigned long long t, a, b;
	cin >> t >> a >> b;
	unsigned long long m = gcd(a, b);
	unsigned long long ans = 0;

	ans += ((t) / (a*b / m)) + (min(a, b) - 1);
	ans += min(((t) % (a*b / m)), (min(a, b) - 1));
	unsigned long long p = ans / m;
	unsigned long long q = t / m;
	cout << p << "/" << q;
	return 0;

}


class DimaAndGuards
{
    static void Main(string[] args)
    {
        string strM = Console.ReadLine();
        int m = int.Parse(strM);
        int[] post1 = new int[4];
        int[] post2 = new int[4];
        int[] post3 = new int[4];
        int[] post4 = new int[4];
        string[] input = Console.ReadLine().Split();
        for (int i = 0; i < 4; i++)
        {
            post1[i] = int.Parse(input[i]);
        }
        input = Console.ReadLine().Split();
        for (int i = 0; i < 4; i++)
        {
            post2[i] = int.Parse(input[i]);
        }
        input = Console.ReadLine().Split();
        for (int i = 0; i < 4; i++)
        {
            post3[i] = int.Parse(input[i]);
        }
        input = Console.ReadLine().Split();
        for (int i = 0; i < 4; i++)
        {
            post4[i] = int.Parse(input[i]);
        }
        findGuardpost(m, post1, post2, post3, post4);
    }

    public void findGuardpost(int m, int[] post1, int[] post2, int[] post3, int[] post4)
    {
        bool found = false;
        int i = 0;
        int j = 0;
        int k = 2;
        int addend1 = 0;
        int addend2 = 0;
        int[] mArr = new int[4];
        for (i = 0; i < 4; i++)
        {
            if (i == 0)
            {
                mArr = post1;
            } else if (i == 1)
            {
                mArr = post2;
            } else if (i == 2)
            {
                mArr = post3;
            } else
            {
                mArr = post4;
            }
            for (j = 0; j <= 1; j++)
            {
                addend1 = mArr[j];
                for (k = 2; k <= 3; k++)
                {
                    addend2 = mArr[k];
                    if (addend1 + addend2 <= m)
                    {
                        if (addend1 + addend2 < m)
                        {
                            int diff = m - (addend1 + addend2);
                            if (addend1 > addend2)
                            {
                                addend2 += diff;
                            }
                            else
                            {
                                addend1 += diff;
                            }
                        }
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    break;
                }
            }
            if (found)
            {
                break;
            }
        }
        if (found)
        {
            Console.WriteLine((i + 1) + " " + addend1 + " " + addend2);
        }
        else
        {
            Console.WriteLine("-1");
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AlgoTraining.Codeforces.VkCup2016
{

    class FastScanner : StreamReader
    {
        private string[] _line;
        private int _iterator;

        public FastScanner(Stream stream) : base(stream)
        {
            _line = null;
            _iterator = 0;
        }
        public int NextInt()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return Convert.ToInt32(_line[_iterator++]);
        }
        public long NextLong()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return Convert.ToInt64(_line[_iterator++]);
        }
    }
    class BearReverseRadewooshA
    {
        public static void Main(string[] args)
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int n = fs.NextInt(), c = fs.NextInt();
                int[] p = new int[n], t = new int[n];
                for (int i = 0; i < n; i++)
                {
                    p[i] = fs.NextInt();
                }
                for (int i = 0; i < n; i++)
                {
                    t[i] = fs.NextInt();
                }
                int limak = 0, radewoosh = 0, time = 0;
                for (int i = 0; i < n; i++)
                {
                    time += t[i];
                    limak += Math.Max(0, p[i] - c * time);
                }
                time = 0;
                for (int i = n - 1; i >= 0; i--)
                {
                    time += t[i];
                    radewoosh += Math.Max(0, p[i] - c * time);
                }
                writer.WriteLine(limak > radewoosh ? "Limak" : radewoosh > limak ? "Radewoosh" : "Tie");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces658A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inp1 = Console.ReadLine().Split();
            string[] inp2 = Console.ReadLine().Split();
            string[] inp3 = Console.ReadLine().Split();

            int n = Convert.ToInt32(inp1[0]);
            int c = Convert.ToInt32(inp1[1]);
            int[] p = new int[n];
            int[] t = new int[n];

            for(int i = 0; i < n; i++)
            {
                p[i] = Convert.ToInt32(inp2[i]);
                t[i] = Convert.ToInt32(inp3[i]);
            }
            int Lim = 0;
            int Rad = 0;

            int penL = 0, penR=0;
            int task = 0;
            for (int i = 0; i < n; i++)
            {
                penL += t[i];
                task = p[i] - penL * c;
                Lim += task > 0 ? task : 0;

                penR += t[n - i - 1];
                task = p[n - i - 1] - penR * c;
                Rad += task > 0 ? task : 0;
            }

            string outp = Lim > Rad ? "Limak" : Lim<Rad ? "Radewoosh" : "Tie";
            Console.WriteLine(outp);
        }
    }
}


using System;

static class Program
{
    static void Main()
    {
        int[][] array = new int[3][];
        array[0] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        array[1] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        array[2] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int limak = 0, radewooosh = 0;
        for (int i = 0; i < array[1].Length; i++)
        {
            int time = 0;
            for (int j = i; j >= 0; j--)
                time += array[2][j];
            limak += Math.Max(0, array[1][i] - array[0][1] * time);
        }
        for (int i = array[1].Length - 1; i >= 0; i--)
        {
            int time = 0;
            for (int j = i; j < array[1].Length; j++)
                time += array[2][j];
            radewooosh += Math.Max(0, array[1][i] - array[0][1] * time);
        }
        Console.WriteLine(limak > radewooosh ? "Limak" : "Radewoosh");

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 1,n2, pad,Ln,Rn,L = 0,R = 0,timel,timer;
            string[] s1, s2, s3;
            s1 = Console.ReadLine().Split();
            s2 = Console.ReadLine().Split();
            s3 = Console.ReadLine().Split();
            pad = Convert.ToInt32(s1[1]);
            timel = Convert.ToInt32(s3[0]);
            timer = Convert.ToInt32(s3[s3.Length-1]);
            n2 = s3.Length - 2;
            for(int m = 0;m<s2.Length;m++)
            {
                Ln = Convert.ToInt32(s2[m]) - pad * timel;
                if(Ln>0)
                {
                    L = L+Ln;
                }

                if (n < s2.Length)
                {
                    timel = timel + Convert.ToInt32(s3[n]);
 n++;
                }
                Rn =  Convert.ToInt32(s2[s2.Length - 1 - m]) - pad * timer;
               if(Rn>0)
               {
                   R = R+Rn;
               }
                if (n2>=0)
                {
                    timer = timer + Convert.ToInt32(s3[n2]);
                    n2--;
                }
            }
            if (L > R)
            {
                Console.Write("Limark");
            }
            if(L<R)
            {
                Console.Write("Radewoosh");
            }
            if(L == R)
            {
                Console.Write("Tie");
            }

        }
    }
}


using System;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');

            var secores= Console.ReadLine().Split(' ');

            var times = Console.ReadLine().Split(' ');

            var length = Convert.ToInt32(inputs[0]);

            var dp = Convert.ToInt32(inputs[1]);

            var Limak = 0;
            var Radewoosh = 0;
            var ttimes = 0;

            for (int i=0;i< length;i++)
            {
                ttimes +=Convert.ToInt32(times[i]);

                var indPoints = Convert.ToInt32(secores[i]) - ttimes * dp;

                    Limak += indPoints;

            }
            ttimes = 0;
            for (int i = length-1; i > 0; i--)
            {
                ttimes += Convert.ToInt32(times[i]);

                var indPoints = Convert.ToInt32(secores[i]) - ttimes * dp;

                    Radewoosh += indPoints;

            }
            if(Limak> Radewoosh)
            {
                Console.WriteLine("Limak");
            }
            else if (Limak < Radewoosh)
            {
                Console.WriteLine("Radewoosh");
            }
            else
            {
                Console.WriteLine("Tie");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

             string[]y=Console.ReadLine().Split(' ');
             string[]y1=Console.ReadLine().Split(' ');
             string[]y2=Console.ReadLine().Split(' ');
             int n=int.Parse(y[0]);
             int c=int.Parse(y[1]);

             int[]a=new int[n];
             int sum1=0;
             int time1=0;
             for(int i=0;i<n;i++)
             a[i]=int.Parse(y1[i]);
             int[]b=new int[n];
             for(int i=0;i<n;i++)
             b[i]=int.Parse(y2[i]);
             for(int i=0;i<n;i++)
             {
                  time1+=b[i];
                  if(a[i]-time1*c>=0)
                  sum1+=a[i]-time1*c;
             }

             int sum2=0;
             int time2=0;

             for(int i=n-1;i>0;i--)
             {
                  time2+=b[i];
                  if(a[i]-time2*c>=0)
                  sum2+=a[i]-time2*c;
             }
             if(sum1>sum2)
             Console.WriteLine("Limak");
             else if(sum1<sum2)
             Console.WriteLine("Radewoosh");
             else
             Console.WriteLine("Tie");
        }

    }
}


using System;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');

            var secores= Console.ReadLine().Split(' ');

            var times = Console.ReadLine().Split(' ');

            var length = Convert.ToInt32(inputs[0]);

            var dp = Convert.ToInt32(inputs[1]);

            var Limak = 0;
            var Radewoosh = 0;
            var ttimes = 0;

            for (int i=0;i< length;i++)
            {
                ttimes +=Convert.ToInt32(times[i]);

                var indPoints = Convert.ToInt32(secores[i]) - ttimes * dp;

                if(indPoints>0)
                {
                    Limak += indPoints;
                }
            }
            ttimes = 0;
            for (int i = length-1; i > 0; i--)
            {
                ttimes += Convert.ToInt32(times[i]);

                var indPoints = Convert.ToInt32(secores[i]) - ttimes * dp;

                if (indPoints > 0)
                {
                    Radewoosh += indPoints;
                }
            }
            if(Limak> Radewoosh)
            {
                Console.WriteLine("Limak");
            }
            else if (Limak < Radewoosh)
            {
                Console.WriteLine("Radewoosh");
            }
            else
            {
                Console.WriteLine("Tie");
            }
        }
    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
class Problem
{
    static void Main()
    {
        //--------------------------------input--------------------------------//

        string[] str = Console.ReadLine().Split();
        int n = Convert.ToInt32( str[0] );
        int c = Convert.ToInt32( str[1] );
        var p = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        var t = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );

        //--------------------------------solve--------------------------------//

        int limak = 0, radewoosh = 0, t_l = 0, t_r = 0;
        for(int i = 0 ; i < n ; i++)
        {
            t_l += t[i];
            t_r += t[n - 1 - i];
            limak += ( p[i] - c * t_l );
            radewoosh += Math.Max( 0, p[n - 1 - i] - c * t_r );
        }

        Console.WriteLine( limak > radewoosh ? "Limak" : limak == radewoosh ? "Tie" : "Radewoosh" );

    }
}


using System;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');

            var secores= Console.ReadLine().Split(' ');

            var times = Console.ReadLine().Split(' ');

            var length = Convert.ToInt32(inputs[0]);

            var dp = Convert.ToDecimal(inputs[1]);

            decimal Limak = 0;
            decimal Radewoosh = 0;
            decimal ttimes = 0;

            for (int i=0;i< length;i++)
            {
                ttimes +=Convert.ToDecimal(times[i]);

                var indPoints = Convert.ToDecimal(secores[i]) - ttimes * dp;

                if(indPoints>0)
                {
                    Limak += indPoints;
                }
            }
            ttimes = 0;
            for (int i = length-1; i > 0; i--)
            {
                ttimes += Convert.ToDecimal(times[i]);

                var indPoints = Convert.ToDecimal(secores[i]) - ttimes * dp;

                if (indPoints > 0)
                {
                    Radewoosh += indPoints;
                }
            }
            if(Limak> Radewoosh)
            {
                Console.WriteLine("Limak");
            }
            else if (Limak < Radewoosh)
            {
                Console.WriteLine("Radewoosh");
            }
            else
            {
                Console.WriteLine("Tie");
            }
        }
    }
}


using System;
using System.Collections.Generic;

namespace first
{
    class Program
    {
        static void Main(string[] args)
        {
            string one = Console.ReadLine();
            string two = Console.ReadLine();
            string three = Console.ReadLine();
            int n = Int32.Parse(one.Split(' ')[0]);
            int c = Int32.Parse(one.Split(' ')[1]);

            int l_time = 0;
            int r_time = 0;

            int l_score = 0;
            int r_score = 0;

            for (int i = 0; i < n; i++)
            {
                l_time += Int32.Parse(three.Split(' ')[i]);
                if ((Int32.Parse(two.Split(' ')[i]) - l_time * c) < 0) continue;
                else l_score += Int32.Parse(two.Split(' ')[i]) - l_time * c;
            }
            for (int i = n-1; i > 0; i--)
            {
                r_time += Int32.Parse(three.Split(' ')[i]);
                if ((Int32.Parse(two.Split(' ')[i]) - r_time * c) < 0) continue;
                else r_score += Int32.Parse(two.Split(' ')[i]) - r_time * c;
            }
            if (l_score > r_score) Console.WriteLine("Limak");
            else if (r_score > l_score) Console.WriteLine("Radewoosh");
            else Console.WriteLine("Tie");

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            int pad,L = 0,R = 0,timel,timer;
            string[] s1, s2, s3;
            s1 = Console.ReadLine().Split();
            s2 = Console.ReadLine().Split();
            s3 = Console.ReadLine().Split();
            pad = Convert.ToInt32(s1[1]);
            timel = Convert.ToInt32(s3[0]);
            timer = Convert.ToInt32(s3[s3.Length-1]);
            for(int m = 0;m<s2.Length;m++)
            {
                L = Convert.ToInt32(s2[m]) - pad * timel;
                timel = timel + Convert.ToInt32(s3[m]);
                R = Convert.ToInt32(s2[s2.Length - 1 - m]) - pad * timer;
                timer = timer + Convert.ToInt32(s3[s3.Length-1-m]);
            }
            if(L>R)
            {
                Console.Write("Limark");
            }
            else
            {
                Console.Write("Radewoosh");
            }
            if(L == R)
            {
                Console.Write("Tie");
            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public Scanner sc;
    public void Solve()
    {
        int N, M;long K;
        sc.Make(out N, out M, out K);
        if (K < N) Fail($"{K+1} {1}");
        if (K == N) Fail($"{K} {2}");
        K -= N;
        long n = K / (M - 1);K /= M - 1;
        long m;
        if (n % 2 == 0) m = K + 2;
        else m = (M - K );
        n = N - n;
        Console.WriteLine($"{n} {m}");
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var sol = new Solver() { sc = new Scanner() };
        //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
        sol.Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int MaxElement<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion


using System;

namespace Lara_Croft_and_the_New_Game
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            ulong n = ulong.Parse(input[0]);
            ulong m = ulong.Parse(input[1]);
            ulong k = ulong.Parse(input[2]);
            ulong X = 0, Y = 0;

            if (k < n) { X = k + 1; Y = 1; }
            else if (k >= n && k < m + n - 2) { X = n; Y = k - n + 2; }
            else
            {
                k -= n + m - 1;
                ulong temp = k / (m - 1);
                X = (n - 1) - temp;
                bool isEven = X % 2 == 0;
                ulong remains = k % (m - 1);
                if (!isEven) Y = m - remains;
                else Y = remains + 2;
            }
            Console.WriteLine("{0} {1}", X, Y);

        }
    }
}


using System;
using System.IO;
using System.Text;

namespace Lara_Croft_and_the_New_Game
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            Solve(args);
            writer.Flush();
        }

        private static void Solve(string[] args)
        {
            long n = Next();
            long m = Next();
            long k = Next();

            if (k < n)
            {
                writer.Write(k + 1);
                writer.WriteLine(" 1");
            }
            else
            {
                long r = (k - n + m - 3)/(m - 1);
                long x = (k - n)%(m - 1);
                writer.Write(n - r);
                writer.Write(' ');
                if (r%2 == 0)
                {
                    writer.Write(2 + x);
                }
                else
                {
                    writer.Write(m - x);
                }
                writer.WriteLine();
            }
        }

        private static long Next()
        {
            int c;
            long res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long x, y,mo,h,l;
            h = 0;
            l = 0;
            string[] inp = Console.ReadLine().Split(' ');
            long n = Convert.ToInt64(inp[0]);
            long m = Convert.ToInt64(inp[1]);
            long k = Convert.ToInt64(inp[2]);
            k = k % (n * 3);
            if (k <= n - 1)
            {
                Console.WriteLine(k + 1 + " " + 1);
            }
            else
            {
                k -= (n - 1);
                mo = m - 1;
                if (k % mo > 0)
                    h = (k / mo) + 1;
                else
                    h = (k / mo);
                if (k % mo == 1)
                    l = k % mo;
                else
                    l = mo;
                if ((h & 1) == 1)
                {
                    l = l + 1;
                    l = mo - l + 2;
                }
                else
                {
                    l = mo - l + 2;
                }
                Console.WriteLine(n - h + 1 + " " + l);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace ConsoleApp3
{
    class Program
    {
        static long n, m, k;
        static void input()
        {
            string[] s = Console.ReadLine().Split();
            n = long.Parse(s[0]);
            m = long.Parse(s[1]);
            k = long.Parse(s[2]);
        }
        static void solve()
        {
            if(k<n)
            {
                Console.WriteLine((k+1)+" 1");
                return;
            }
            m--;
            k = k - (n - 1);
            long t = (k-1) / m;
            Console.Write(n-t+" ");
            if (t % 2 == 0)
            {
                t = (k - 1) % m;
                Console.WriteLine(t+1);
            }
            else
            {
                t = (k - 1) % m;
                m = m - t+1;
                Console.WriteLine(m);
            }

        }
        static void Main(string[] args)
        {
            input();
            solve();
        }
    }
}


using System;

namespace CSharp
{
    class _976B
    {
        public static void Main()
        {
            var tokens = Console.ReadLine().Split();

            long n = long.Parse(tokens[0]);
            long m = long.Parse(tokens[1]);
            long k = long.Parse(tokens[2]);

            if (k < n)
            {
                Console.WriteLine($"1 {1 + k}");
            }
            else
            {
                k -= n;
                m--;

                long row = n - k / m;
                long column = (n - row) % 2 == 0 ? 2 + k % m : m + 1 - k % m;

                Console.WriteLine($"{row} {column}");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long mo,h,l;
            h = 0;
            l = 0;
            string[] inp = Console.ReadLine().Split(' ');
            long n = Convert.ToInt64(inp[0]);
            long m = Convert.ToInt64(inp[1]);
            long k = Convert.ToInt64(inp[2]);
         //   k = k % (n * 3);
            if (k <= n - 1)
            {
                Console.WriteLine(k + 1 + " " + 1);
            }
            else
            {
                k -= (n - 1);
                mo = m - 1;
                if (k % mo > 0)
                    h = (k / mo) + 1;
                else
                    h = (k / mo);
                if (k % mo == 1)
                    l = k % mo;
                else
                    l = mo;
                if ((h & 1)==1)
                {
                    l = l + 1;
                }
                else
                {
                    l = mo - l + 2;
                }
                Console.WriteLine(n - h + 1 + " " + l);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public Scanner sc;
    public void Solve()
    {
        int N, M;long K;
        sc.Make(out N, out M, out K);
        if (K < N) Fail($"{K+1} {1}");
        if (K == N) Fail($"{K} {2}");
        K -= N;
        long n = K / (M - 1);K /= M - 1;
        long m;
        if (n % 2 == 0) m = K % (N - 1) + 2;
        else m = (M - K );
        n = N - n;
        Console.WriteLine($"{n} {m}");
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var sol = new Solver() { sc = new Scanner() };
        //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
        sol.Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int MaxElement<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long x, y,mo,h,l;
            h = 0;
            l = 0;
            string[] inp = Console.ReadLine().Split(' ');
            long n = Convert.ToInt64(inp[0]);
            long m = Convert.ToInt64(inp[1]);
            long k = Convert.ToInt64(inp[2]);
         //   k = k % (n * 3);
            if (k <= n - 1)
            {
                Console.WriteLine(k + 1 + " " + 1);
            }
            else
            {
                k -= (n - 1);
                mo = m - 1;
                if (k % mo > 0)
                    h = (k / mo) + 1;
                else
                    h = (k / mo);
                if (k % mo == 1)
                    l = k % mo;
                else
                    l = mo;
                if ((h & 1) == 1)
                {
                    l = l + 1;
                    l = mo - l + 2;
                }
                else
                {
                    l = mo - l + 2;
                }
                Console.WriteLine(n - h + 1 + " " + l);
            }
        }
    }
}


using System;

namespace LaraNewGame976B
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			Int32 n, m;
			Int64 k;
			string[] tokens = Console.ReadLine().Split();
			n = Int32.Parse(tokens[0]);
			m = Int32.Parse(tokens[1]);
			k = Int64.Parse(tokens[2]);

			if (k < n)
			{
				Console.WriteLine("{0} {1}", k + 1, 1);
			}
			else
			{
				k -= n;
				Int64 leftLevels = k / (m - 1);
				Int64 leftSteps = k % (m - 1);
				if (leftLevels % 2 == 0)
				{
					Console.WriteLine("{0} {1}", n - leftLevels, leftSteps + 2);
				}
				else
				{
					Console.WriteLine("{0} {1}", n - leftLevels, m - leftSteps);
				}
			}
		}
	}
}


using System;
using System.IO;
using System.Text;

namespace Lara_Croft_and_the_New_Game
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            Solve(args);
            writer.Flush();
        }

        private static void Solve(string[] args)
        {
            long n = Next();
            long m = Next();
            long k = Next();

            if (k < n)
            {
                writer.Write(k + 1);
                writer.WriteLine(" 1");
            }
            else
            {
                long r = (k - n)/(m - 1);
                long x = (k - n)%(m - 1);
                writer.Write(n - r);
                writer.Write(' ');
                if (r%2 == 0)
                {
                    writer.Write(2 + x);
                }
                else
                {
                    writer.Write(m - x);
                }
                writer.WriteLine();
            }
        }

        private static long Next()
        {
            int c;
            long res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace ConsoleApp3
{
    class Program
    {
        static long n, m, k;
        static void input()
        {
            string[] s = Console.ReadLine().Split();
            n = long.Parse(s[0]);
            m = long.Parse(s[1]);
            k = long.Parse(s[2]);
        }
        static void solve()
        {
            if(k<n)
            {
                Console.WriteLine((k+1)+" 1");
                return;
            }
            m--;
            k = k - (n - 1);
            long t = (k-1) / m;
            Console.Write(n-t+" ");
            if (t % 2 == 0)
            {
                t = (k - 1) % m;
                Console.WriteLine(t+2);
            }
            else
            {
                t = (k - 1) % m;
                m = m - t+1;
                Console.WriteLine(m);
            }

        }
        static void Main(string[] args)
        {
            input();
            solve();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TaskB
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();

            var n = arr[0];
            var m = arr[1];
            var k = arr[2];

            var res = Calc(n, m, k);
            Console.Write($"{res[0]} {res[1]}");
        }

        static long[] Calc(long n, long m, long k)
        {
            long x = 1, y = 1;

            //вниз
            var res = k - (n - 1);
            if (res < 0)
            {
                x = k + 1;
                return new long[2] { x, y };
            }

            //вправо
            k = res;
            res = k - (m - 1);
            if (res < 0)
            {
                y = k + 1;
                x = n;
                return new long[2] { x, y };
            }

            //кол-во змеек: (1 вверх и до конца влево (или вправо))
            k = res;
            var kolLeft = k / (m - 1);
            var ost = k % (m - 1);

            if ((kolLeft % 2 == 0 && ost > 0) || (kolLeft % 2 == 1 && ost == 0))
                //четное с ненулевым ост или нечетное с нулевым => закончим на пути 1 вверх потом влево
            {
                x = ost == 0 ? n - kolLeft : n - kolLeft - 1;
                y = ost == 0 ? 2 : m + 1 - ost;
                return new long[2] { x, y };
            }

            //нечетное с ненулевым или четное с нулевым, закончим на пути 1 вверх потом вправо
            x = ost == 0 ? n - kolLeft : n - 1 - kolLeft;
            y = ost == 0 ? m : 2 + ost - 1;
            return new long[2] { x, y };
        }
    }
}


using System;

namespace _976B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(new char[] {' '});

            long n = long.Parse(inputs[0]);
            long m = long.Parse(inputs[1]);
            long k = long.Parse(inputs[2]);

            long x = 1;
            long y = 1;

            if(k == 0)
            {
                Console.Write($"{x} {y}");
                return;
            }

            if(k < n)
            {
                x += k;
                Console.Write($"{x} {y}");
                return;
            }

            if(k == n)
            {
                x = n;
                y++;

                Console.Write($"{x} {y}");
                return;
            }

            k -= n;
            x = n;

            long up = k / (m - 1);
            long step = k % (m - 1);
            x -= up;

            if(up % 2 == 0)
            {
                y = 2 + step;
            }
            else
            {
                y = m - step;
            }

            Console.Write($"{x} {y}");
            return;
        }
    }
}


using System;
using System.Linq;

namespace LaraCroft
{
    class Program
    {
        struct Vector2
        {
            public long X;
            public long Y;

            public Vector2(long x, long y)
            {
                this.X = x;
                this.Y = y;
            }

            public override string ToString()
            {
                return $"{this.Y} {this.X}";
            }
        }

        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            var values = words.Select(long.Parse).ToArray();

            var sizeY = values[0];
            var sizeX = values[1];
            var moves = values[2];

            Console.Write(SimulateMoves(sizeX, sizeY, moves));
        }

        static Vector2 SimulateMoves(long sizeX, long sizeY, long moves)
        {
            if (moves < sizeY)
            {
                return new Vector2(1, (long) moves + 1);
            }

            moves -= sizeY;
            var result = new Vector2(2, sizeY);
            var halfDividor = sizeX - 1;
            var dividor = halfDividor * 2;
            var yJumps = moves / dividor;
            moves -= yJumps * dividor;
            result.Y -= yJumps * 2;

            if (moves < halfDividor)
            {
                result.X += moves;
                return result;
            }
            else
            {
                moves -= halfDividor;
                result.X = sizeX;
                result.Y -= 1;
                result.X -= moves;
                return result;
            }
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){

		if(K <= N - 1){
			Console.WriteLine("{0} {1}",1 + K, 1);
			return;
		}

		K -= N;
		long rr = K / (2 * M - 2);
		long cc = K % (2 * M - 2);

		long r2 = cc / (M - 1);

		long r = N - 2 * rr - r2;
		long c = 2;
		if(cc < M - 1){
			c += cc;
		} else {
			c += M - 1 - (cc - (M - 1)) - 1;
		}
		Console.WriteLine("{0} {1}",r,c);

	}

	long N,M,K;
	public Sol(){
		var d = rla();
		N = d[0]; M = d[1]; K = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long mo,h,l;
            h = 0;
            l = 0;
            string[] inp = Console.ReadLine().Split(' ');
            long n = Convert.ToInt64(inp[0]);
            long m = Convert.ToInt64(inp[1]);
            long k = Convert.ToInt64(inp[2]);
         //   k = k % (n * 3);
            if (k <= n - 1)
            {
                Console.WriteLine(k + 1 + " " + 1);
            }
            else
            {
                k -= (n - 1);
                mo = m - 1;
                if (k % mo > 0)
                    h = (k / mo) + 1;
                else
                    h = (k / mo);
                if ((k % mo)>0)
                    l = k % mo;
                else
                    l = mo;
                if ((h & 1)==1)
                {
                    l = l + 1;
                }
                else
                {
                    l = mo - l + 2;
                }
                Console.WriteLine(n - h + 1 + " " + l);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public Scanner sc;
    public void Solve()
    {
        int N, M;long K;
        //N = 4; M = 2;K = 6;
        sc.Make(out N, out M, out K);
        if (K < N) Fail($"{K+1} {1}");
        if (K == N) Fail($"{K} {2}");
        K -= N;
        long n = K / (M - 1);K %= M - 1;
        long m;
        if (n % 2 == 0) m = K + 2;
        else m = (M - K );
        n = N - n;
        Console.WriteLine($"{n} {m}");
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var sol = new Solver() { sc = new Scanner() };
        //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
        sol.Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int MaxElement<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;
using System.Security.Policy;
using System.Threading;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N, M;
        private long K;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            M = sc.NextInt();
            K = sc.NextLong();
        }

        public void Solve()
        {
            Scan();
            if (K < N)
            {
                Console.WriteLine($"{K + 1} {1}");
            }
            else
            {
                long d = K - N;
                long x;
                long y = N - d / (M - 1);
                if ((d / (M - 1)) % 2 == 0)
                {
                    x = d % (M - 1) + 2;

                }
                else
                {
                    x = M - d % (M - 1);

                }
                Console.WriteLine($"{y} {x}");
            }
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}


using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long n = Convert.ToInt64(s.Split(' ')[0]);
            long m = Convert.ToInt64(s.Split(' ')[1]);
            long k = Convert.ToInt64(s.Split(' ')[2]);
            long x = 1, y = 1;
            if (k + 1 <= n)
                x += k;
            else
            {
                x = n;
                k -= n - 1;
                y++; k--;
                long lines = k / (m - 1);
                long rem = k % (m - 1);
                x -= lines;
                if (lines == n)
                    x = 1;
                if (lines % 2 == 0)
                    y += rem;
                else
                    y = m - rem;
            }
            Console.WriteLine(x + " " + y);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LaraKroft
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            ulong n = ulong.Parse(s[0]);
            ulong m = ulong.Parse(s[1]);
            ulong k = ulong.Parse(s[2]);

            ulong row = 0;
            ulong col = 0;

            if (k<=n-1)
            {
                row = 1 + k;
                col = 1;
            }
            else
            {
                k -= n - 1;
                if (k <= m - 1)
                {
                    col = 1 + k;
                    row = n;
                }
                else
                {
                    k -= m ;
                    row = n - k / (m - 1)-1;

                    if (row % 2 == 1)
                        col = m - k % (m - 1);
                    else
                        col = 2 + k % (m - 1);
                }
            }

            Console.Write("{0} {1}", row, col);

        }
    }
}


using System;

namespace _976B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(" ");

            long n = long.Parse(inputs[0]);
            long m = long.Parse(inputs[1]);
            long k = long.Parse(inputs[2]);

            long x = 1;
            long y = 1;

            if(k == 0)
            {
                Console.Write($"{x} {y}");
                return;
            }

            if(k < n)
            {
                x += k;
                Console.Write($"{x} {y}");
                return;
            }

            if(k == n)
            {
                x = n;
                y++;

                Console.Write($"{x} {y}");
                return;
            }

            k -= n;
            x = n;

            long up = k / (m - 1);
            long step = k % (m - 1);
            x -= up;

            if(up % 2 == 0)
            {
                y = 2 + step;
            }
            else
            {
                y = m - step;
            }

            Console.Write($"{x} {y}");
            return;
        }
    }
}


using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string l = Console.ReadLine();
            long n = Convert.ToInt64(l.Split(' ')[0]);
            long m = Convert.ToInt64(l.Split(' ')[1]);
            long k = Convert.ToInt64(l.Split(' ')[2]);
            int x = 1, y = 1;
            bool snake = false;
            bool goRight = true;
            while(k > 0)
            {
                if (x == n)
                {
                    snake = true;
                }
                //reached destination
                if (x == 1 && y == 2)
                {
                    k = 0;
                    break;
                }
                //going down along the left side
                else if (snake == false && x < n)
                {
                    x++;
                    k--;
                }
                else if(snake && goRight)
                {
                    if (y < m)
                    {
                        k--;
                        y++;
                    }
                    else if(y == m)
                    {
                        x--;
                        k--;
                        goRight = false;
                    }
                }
                else if(snake && goRight == false)
                {
                    if(y > 2)
                    {
                        y--;
                        k--;
                    }
                    else if(y == 2)
                    {
                        k--;
                        x--;
                        goRight = true;
                    }
                }
                //Console.WriteLine(x + " " + y);
            }
            Console.WriteLine(x + " " + y);
        }
    }
}


using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string l = Console.ReadLine();
            long n = Convert.ToInt64(l.Split(' ')[0]);
            long m = Convert.ToInt64(l.Split(' ')[1]);
            long k = Convert.ToInt64(l.Split(' ')[2]);
            long x = 1, y = 1;
            bool snake = false;
            bool goRight = true;
            while(k > 0)
            {
                if (x == n)
                {
                    snake = true;
                }
                if (x == 1 && y == 2)
                {
                    k = 0;
                    break;
                }
                else if (snake == false && x < n)
                {
                    if(n <= k)
                    {
                        x = n;
                        snake = true;
                        k -= n - 1;
                    }
                    else
                    {
                        x++;
                        k--;
                    }
                }
                else if(snake && goRight)
                {
                    if (y < m)
                    {
                        if(k >= m-y)
                        {
                            k -= m - y + 1;
                            y = m;
                            x--;
                            goRight = false;
                        }
                        else
                        {
                            k--;
                            y++;
                        }
                    }
                    else if(y == m)
                    {
                        x--;
                        k--;
                        goRight = false;
                    }
                }
                else if(snake && goRight == false)
                {
                    if(y > 2)
                    {
                        if (k >= m - 1)
                        {
                            k -= m - 1;
                            y = 2;
                            x--;
                            goRight = true;
                        }
                        else
                        {
                            y--;
                            k--;
                        }
                    }
                    else if(y == 2)
                    {
                        k--;
                        x--;
                        goRight = true;
                    }
                }
                //Console.WriteLine(x + " " + y + " " + k);
            }
            Console.WriteLine(x + " " + y);
            //Console.ReadKey();
        }
    }
}


using System;
using System.Linq;
using CompLib.Util;
using System.Threading;
using System.IO;
using System.Collections.Generic;
using System.Text;
using CompLib.Mathematics;

public class Program
{
    int N, K;
    BinomialCoefficient Binom;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();

        // 2^n人 n回戦トーナメント

        // 優勝が小さい方が良い
        // トーナメントの構築、勝つ人決める

        // K回以下 結果変えられる

        // 可能な勝つ人最小

        if (K >= N)
        {
            Console.WriteLine(ModInt.Pow(2, N));
            return;
        }

        Binom = new BinomialCoefficient(N);
        ModInt ans = 0;
        for (int i = 0; i <= K; i++)
        {
            ans += Binom[N, i];
        }

        Console.WriteLine(ans);

        // 1 1 + N
        // 2 1 + N + 1 + 2 + 3 + ... (N-1)

        // 1 + 3 + (1 + 2)
    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt
    /// <summary>
    /// [0,<see cref="Mod"/>) までの値を取るような数
    /// </summary>
    public struct ModInt
    {
        /// <summary>
        /// 剰余を取る値．
        /// </summary>
        public const long Mod = (int)1e9 + 7;
        // public const long Mod = 998244353;

        /// <summary>
        /// 実際の数値．
        /// </summary>
        public long num;
        /// <summary>
        /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
        /// </summary>
        /// <param name="n">インスタンスが持つ値</param>
        /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
        public ModInt(long n) { num = n; }
        /// <summary>
        /// このインスタンスの数値を文字列に変換します．
        /// </summary>
        /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
        public override string ToString() { return num.ToString(); }
        public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
        public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
        public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
        public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(long v, long k)
        {
            long ret = 1;
            for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
                if ((k & 1) == 1) ret = ret * v % Mod;
            return new ModInt(ret);
        }
        /// <summary>
        /// 与えられた数の逆元を計算します．
        /// </summary>
        /// <param name="v">逆元を取る対象となる数</param>
        /// <returns>逆元となるような値</returns>
        /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
        public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
    }
    #endregion
    #region Binomial Coefficient
    public class BinomialCoefficient
    {
        public ModInt[] fact, ifact;
        public BinomialCoefficient(int n)
        {
            fact = new ModInt[n + 1];
            ifact = new ModInt[n + 1];
            fact[0] = 1;
            for (int i = 1; i <= n; i++)
                fact[i] = fact[i - 1] * i;
            ifact[n] = ModInt.Inverse(fact[n]);
            for (int i = n - 1; i >= 0; i--)
                ifact[i] = ifact[i + 1] * (i + 1);
            ifact[0] = ifact[1];
        }
        public ModInt this[int n, int r]
        {
            get
            {
                if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
                return fact[n] * ifact[n - r] * ifact[r];
            }
        }
        public ModInt RepeatedCombination(int n, int k)
        {
            if (k == 0) return 1;
            return this[n + k - 1, k];
        }
    }
    #endregion
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {

            var arr = Console.ReadLine().Split(' ');
            var n = Int32.Parse(arr[0]);
            var k = Int32.Parse(arr[1]);

            Console.WriteLine(GetVal(n,k));
        }

        const int MOD_VAL = 1000000007;

        private static int GetVal(int n, int k)
        {
            var res = 1;
            if(k >= n)
            {
                for(var i = 0;i<n;i++)
                {
                    res = (res * 2) % MOD_VAL;
                }
                return res;
            }

            var factorials = GetFactorials(n);
            var revals = GetRevals(n, factorials[n]);

            for(var i = 1;i<=k;i++)
            {
                res = (int)((res + (long)factorials[n]*revals[i] % MOD_VAL * revals[n-i] % MOD_VAL) % MOD_VAL);
            }
            return res;
        }

        private static (int,int) ExGcd(int num0, int num1)
        {
            if (num0 % num1 == 0)
            {
                return (0, 1);
            }
            // a0 * num0 + b0 * num1 = num2
            var num2 = num0 % num1;
            var a0 = 1;
            var b0 = - (num0 / num1);
            // a1 * num1 + b1 * num2 = gcd
            var (a1,b1) = ExGcd(num1, num2);
            // (a0*b1) * num0 + (a1 + b0*b1) * num1 = gcd
            return (a0*b1, a1 + b0*b1);
        }

        private static int[] GetRevals(int n, int factorial)
        {
            var (_, tmpVal) = ExGcd(MOD_VAL, factorial);
            if(tmpVal < 0) tmpVal+=MOD_VAL;
            var revals = new int[n+1];
            revals[n] = tmpVal;
            for(var i = n-1;i>=0;i--)
            {
                revals[i] = (int)((long)revals[i+1] * (i+1) % MOD_VAL);
            }
            return revals;
        }

        private static int[] GetFactorials(int n)
        {
            var factorials = new int[n+1];
            factorials[0] = 1;
            for(var i = 1;i<=n;i++)
            {
                factorials[i] = (int)((long)factorials[i-1] * i % MOD_VAL);
            }
            return factorials;
        }

    }
}


using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces800
{
    internal static class Program
    {
        public static long prime = 1000000007;
        public static long[] bprime = new long[2];
        public static Dictionary<long, long> invar = new Dictionary<long, long>();
        public static long[] fact = new long[1];
        public static void Main()
        {
            var cur = prime - 2;
            var list = new List<long>();
            while (cur != 0)
            {
                list.Add(cur % 2);
                cur = cur / 2;
            }
            bprime = list.ToArray();
            var str = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToList();
            var n = str[0];
            var k = str[1];
            long res = 0;
            fact = new long[n + 1];
            fact[0] = 1;
            for (var i = 1; i < n + 1; i++)
            {
                fact[i] = (long)((long)fact[i - 1] * i) % prime;
            }
            for (var i = 0; i <= Math.Min(n,k); i++)
            {
                res += C(n, i);
                res = res % prime;
            }
            Console.WriteLine(res);
        }
        private static long C(long n, long k)
        {
            if (n >= k)
            {
                long res = fact[n];
                res = res * calcInv(fact[n - k]);
                res = res % prime;
                res = res * calcInv(fact[k]);
                res = res % prime;
                return (long)res;
            }
            else return 0;
        }

        public static long calcInv(long n)
        {
            if (invar.TryGetValue(n, out var invn))
                return invn;
            else
            {
                var ost = new long[bprime.Length];
                ost[0] = n;
                for (var i = 1; i < bprime.Length; i++)
                {
                    ost[i] = (ost[i - 1] * ost[i - 1]) % prime;
                }
                long inv = 1;
                for (var i = 0; i < bprime.Length; i++)
                {
                    inv *= (bprime[i] == 1) ? ost[i] : 1;
                    inv = inv % prime;
                }
                invar.Add(n, (long)inv);

                return (long)inv;
            }
        }
    }
}


using System;
using System.Linq;
using CompLib.Util;
using System.Threading;
using System.IO;
using System.Collections.Generic;
using System.Text;
using CompLib.Mathematics;

public class Program
{
    int N, K;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();

        // 2^n人 n回戦トーナメント

        // 優勝が小さい方が良い
        // トーナメントの構築、勝つ人決める

        // K回以下 結果変えられる

        // 可能な勝つ人最小

        if (K >= N)
        {
            Console.WriteLine(ModInt.Pow(2, N));
            return;
        }

        ModInt ans = 0;
        for (int i = 0; i < K; i++)
        {
            ans += ModInt.Pow(2, N - i - 1);
        }
        Console.WriteLine(ans + 1);
    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt
    /// <summary>
    /// [0,<see cref="Mod"/>) までの値を取るような数
    /// </summary>
    public struct ModInt
    {
        /// <summary>
        /// 剰余を取る値．
        /// </summary>
        public const long Mod = (int)1e9 + 7;
        // public const long Mod = 998244353;

        /// <summary>
        /// 実際の数値．
        /// </summary>
        public long num;
        /// <summary>
        /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
        /// </summary>
        /// <param name="n">インスタンスが持つ値</param>
        /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
        public ModInt(long n) { num = n; }
        /// <summary>
        /// このインスタンスの数値を文字列に変換します．
        /// </summary>
        /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
        public override string ToString() { return num.ToString(); }
        public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
        public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
        public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
        public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(long v, long k)
        {
            long ret = 1;
            for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
                if ((k & 1) == 1) ret = ret * v % Mod;
            return new ModInt(ret);
        }
        /// <summary>
        /// 与えられた数の逆元を計算します．
        /// </summary>
        /// <param name="v">逆元を取る対象となる数</param>
        /// <returns>逆元となるような値</returns>
        /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
        public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
    }
    #endregion
    #region Binomial Coefficient
    public class BinomialCoefficient
    {
        public ModInt[] fact, ifact;
        public BinomialCoefficient(int n)
        {
            fact = new ModInt[n + 1];
            ifact = new ModInt[n + 1];
            fact[0] = 1;
            for (int i = 1; i <= n; i++)
                fact[i] = fact[i - 1] * i;
            ifact[n] = ModInt.Inverse(fact[n]);
            for (int i = n - 1; i >= 0; i--)
                ifact[i] = ifact[i + 1] * (i + 1);
            ifact[0] = ifact[1];
        }
        public ModInt this[int n, int r]
        {
            get
            {
                if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
                return fact[n] * ifact[n - r] * ifact[r];
            }
        }
        public ModInt RepeatedCombination(int n, int k)
        {
            if (k == 0) return 1;
            return this[n + k - 1, k];
        }
    }
    #endregion
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces800
{
    internal static class Program
    {
        public static long prime = 1000000007;
        public static long[] bprime = new long[2];
        public static Dictionary<long, long> invar = new Dictionary<long, long>();
        public static long[] fact = new long[1];
        public static void Main()
        {
            var cur = prime - 2;
            var list = new List<long>();
            while (cur != 0)
            {
                list.Add(cur % 2);
                cur = cur / 2;
            }
            bprime = list.ToArray();
            var str = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToList();
            var n = str[0];
            var k = str[1];
            long res = 0;
            fact = new long[n + 1];
            fact[0] = 1;
            for (var i = 1; i < n + 1; i++)
            {
                fact[i] = (long)((long)fact[i - 1] * i) % prime;
            }
            for (var i = 0; i <= k; i++)
            {
                res += C(n, i);
                res = res % prime;
            }
            Console.WriteLine(res);
        }
        private static long C(long n, long k)
        {
            if (n >= k)
            {
                long res = fact[n];
                res = res * calcInv(fact[n - k]);
                res = res % prime;
                res = res * calcInv(fact[k]);
                res = res % prime;
                return (long)res;
            }
            else return 0;
        }

        public static long calcInv(long n)
        {
            if (invar.TryGetValue(n, out var invn))
                return invn;
            else
            {
                var ost = new long[bprime.Length];
                ost[0] = n;
                for (var i = 1; i < bprime.Length; i++)
                {
                    ost[i] = (ost[i - 1] * ost[i - 1]) % prime;
                }
                long inv = 1;
                for (var i = 0; i < bprime.Length; i++)
                {
                    inv *= (bprime[i] == 1) ? ost[i] : 1;
                    inv = inv % prime;
                }
                invar.Add(n, (long)inv);

                return (long)inv;
            }
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using System.Numerics;
using static System.Math;
using static System.Console;
using Number = System.Int64;
namespace Program {
	public class Solver {
		Random rnd = new Random();
		public void Solve() {
			var n = ri; BigInteger k = rl; var m = ri;
			var s = "";
			for (int i = 0; i < m; i++) {
				var cnt = f(s + "0", n);
				//Console.WriteLine($"now {s + '0'} {cnt} {k}");
				if (k <= cnt) {
					s += "0";
					var u = f(s + "0", n);
					var v = f(s + "1", n);
					//Console.WriteLine($"{s} {cnt} {u} {v} {cnt - u - v}");
					if (cnt - u - v != 0) k--;
				}
				else {
					k -= cnt;
					s += "1";
					var x = f(s, n);
					var u = f(s + "0", n);
					var v = f(s + "1", n);
					//onsole.WriteLine($"{s} {cnt} {x} {u} {v} {x - u - v}");
					if (x - u - v != 0) k--;
				}
				if (k <= 0) break;
			}
			Console.WriteLine(s);
		}
		BigInteger f(string p, int n) {
			//Console.WriteLine($"func {p}");
			var s = "0";
			var t = "1";
			var a = count(s, p);
			var b = count(t, p);

			var m = p.Length;
			if (n == 0) return a;
			else if (n == 1) return a + b + count(s + t, p);
			for (int len = 1; len < n; len++) {

				var tmp = new SB();
				var nt = new SB();
				if (len > 10) {
					//nt.Append(s.Substring(0, Min(s.Length, m - 1)));
					//tmp.Append(s.Reverse().Take(Min(s.Length, m - 1)).Reverse().AsString());
					for (int i = 0; i < Min(s.Length, m - 1); i++) nt.Append(s[i]);
					for (int i = Min(m - 2, s.Length - 1); i >= 0; i--) tmp.Append(s[s.Length - 1 - i]);
					//nt.Append(t.Reverse().Take(Min(t.Length, m - 1)).Reverse().AsString());
					//tmp.Append(t.Substring(0, Min(t.Length, m - 1)));
					for (int i = Min(m - 2, t.Length - 1); i >= 0; i--) nt.Append(t[t.Length - 1 - i]);
					for (int i = 0; i < Min(t.Length, m - 1); i++) tmp.Append(t[i]);
					//Console.WriteLine($"tmp {tmp.ToString()}");
					var nb = a + b + count(tmp.ToString(), p);
					a = b;
					b = nb;
					s = t;
					t = nt.ToString();
				}
				else {
					nt.Append(s + t);
					var nb = count(nt.ToString(), p);
					a = b;
					b = nb;
					s = t;
					t = nt.ToString();
				}
			}
			return b;
		}
		BigInteger count(string s, string p) {
			var n = s.Length;
			var m = p.Length;
			var z = stringEx.ZAlgorithm(p + "#" + s);
			long cnt = 0;
			for (int i = 0; i < n; i++)
				if (z[i + 1 + m] >= m) cnt++;
			//Console.WriteLine($"count {s} {p} {cnt}");
			return cnt;
		}

		const long INF = 1L << 60;
		static int[] dx = { -1, 0, 1, 0 };
		static int[] dy = { 0, 1, 0, -1 };
		int ri { get { return sc.Integer(); } }
		long rl { get { return sc.Long(); } }
		double rd { get { return sc.Double(); } }
		string rs { get { return sc.Scan(); } }
		public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

		static T[] Enumerate<T>(int n, Func<int, T> f) {
			var a = new T[n];
			for (int i = 0; i < n; ++i) a[i] = f(i);
			return a;
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}

#region main
static class Ex {
	static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
	static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
		return string.Join(st, ie);
	}
	static public void Main() {
		Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });
		var solver = new Program.Solver();
		solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

	public class Printer : StreamWriter {
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
	}

	public class StreamScanner {
		public StreamScanner(Stream stream) { str = stream; }

		public readonly Stream str;
		private readonly byte[] buf = new byte[1024];
		private int len, ptr;
		public bool isEof = false;
		public bool IsEndOfStream { get { return isEof; } }

		private byte read() {
			if (isEof) return 0;
			if (ptr >= len) {
				ptr = 0;
				if ((len = str.Read(buf, 0, 1024)) <= 0) {
					isEof = true;
					return 0;
				}
			}
			return buf[ptr++];
		}

		public char Char() {
			byte b = 0;
			do b = read(); while ((b < 33 || 126 < b) && !isEof);
			return (char)b;
		}
		public string Scan() {
			var sb = new StringBuilder();
			for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
			return sb.ToString();
		}
		public string ScanLine() {
			var sb = new StringBuilder();
			for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
			return sb.ToString();
		}
		public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
		public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
		public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
	}
}

#endregion

#region Z algorithm
static public partial class stringEx {
	/// <summary> <paramref name="s"/> と <paramref name="s"/>[i:] の最長共通接頭辞を O(|<paramref name="s"/>|) で求める。</summary>
	static public int[] ZAlgorithm(string s) {
		var a = new int[s.Length + 1];
		a[0] = s.Length;
		int i = 1, j = 0;
		while (i < s.Length) {
			while (i + j < s.Length && s[j] == s[i + j]) ++j;
			a[i] = j;
			if (j == 0) { ++i; continue; }
			int k = 1;
			while (i + k < s.Length && k + a[k] < j) { a[i + k] = a[k]; ++k; }
			i += k; j -= k;
		}
		return a;
	}
}
#endregion