/*
csc -debug D.cs && mono --debug D.exe <<< "

{ max = 100, ops1 = 382, ops2 = 2182 }
{ max = 100 }
Total counts: 3913
Different GCDs: 382
Max number of divisors: 11 (60 72 84 90 96)

{ max = 1000, ops1 = 6069, ops2 = 61945 }
{ max = 1000 }
Total counts: 391617
Different GCDs: 6069
Max number of divisors: 31 (840)

{ max = 10000, ops1 = 83668, ops2 = 1326800 }
{ max = 10000 }
Total counts: 39205029
Different GCDs: 83668
Max number of divisors: 63 (7560 9240)

{ max = 100000, ops1 = 1066750, ops2 = 24091272 }
{ max = 100000 }
Total counts: 3920698493
Different GCDs: 1066750
Max number of divisors: 127 (83160 98280)
*/

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

public class HelloWorld {
    const ulong MOD = 1000000007ul;

    public static void SolveCodeForces() {
        // ShowStats();
        Solve();
    }

    static void Solve() {
        var max = cin.NextInt();

        var Divs = Helpers.CreateArray(max + 1, _ => new List<int>());
        for (var g = 2; g <= max; g++)
            for (var a = g; a <= max; a += g)
                Divs[a].Add(g);

        var Map = Helpers.CreateArray(max + 1, _ => new Dictionary<int, int>());
        for (var g = 2; g <= max; g++) {
            var counter = Map[g];
            var divs = Divs[g];

            counter[g] = max / g;
            for (var i = divs.Count - 2; i >= 0; i--) {
                var sum = 0;
                for (var j = i + 1; j < divs.Count; j++)
                    if (divs[j] % divs[i] == 0)
                        sum += counter[divs[j]];
                counter[divs[i]] = max / divs[i] - sum;
            }
        }

// for (var g = 2; g <= max; g++) {
//     System.Console.WriteLine(new {g});
//     foreach (var kvp in Map[g])
//         System.Console.WriteLine("   " + new { gcd=kvp.Key, cnt=kvp.Value });
// }

        var maxU = (ulong)max;
        var anssum = 0ul;
        var F = new ulong[max + 1];
        for (var g = 2; g <= max; g++) {
            var ag = 0;
            var sum = 0ul;
            foreach (var kvp in Map[g]) {
                var gcd = kvp.Key;
                var count = kvp.Value;
                if (gcd == g)
                    ag = count;
                else
                    sum = (sum + F[gcd] * (ulong)count) % MOD;
            }
            F[g] = (maxU + sum) * ModInverse(maxU + MOD - (ulong)ag, MOD) % MOD;
            anssum = (anssum + F[g]) % MOD;

// System.Console.WriteLine(new { g, fg=F[g] });
        }

        var ans = (1ul + anssum * ModInverse(maxU, MOD)) % MOD;
        System.Console.WriteLine(ans);
    }

    public static ulong ModInverse(ulong x, ulong mod) { return ModPow(x, mod - 2L, mod); }

    public static ulong ModPow(ulong x, ulong exp, ulong mod) {
        ulong ret = 1ul;
        while (exp > 0) {
            if (exp % 2 == 1) ret = ret * x % mod;
            x = x * x % mod;
            exp /= 2;
        }
        return ret;
    }

    static void ShowStats() {
        foreach (var max in new[] { 100, 1000, 10000, 100000 }) {
            // var MapBrute = GetGcdsCounter_Brute(max);
            var Map = GetGcdsCounter_InnerLoop(max);
            System.Console.WriteLine(new { max });
            // Compare(Map, MapBrute);
            System.Console.WriteLine("Total counts: " + Map.Sum(c => (long)c.Dict.Values.Sum()));
            System.Console.WriteLine("Different GCDs: " + Map.Sum(c => c.Dict.Count));
            var maxcnt = Map.Max(c => c.Dict.Count);
            System.Console.WriteLine("Max number of divisors: {0} ({1})", maxcnt, Map.Select((c, i) => new { c, i }).Where(a => a.c.Dict.Count == maxcnt).Select(a => a.i).Join());
            System.Console.WriteLine();
        }
    }

    static Counter<int>[] GetGcdsCounter_InnerLoop(int max) {
        var Map = Helpers.CreateArray(max + 1, _ => new Counter<int>());

        var ops1 = 0;
        for (var g = 2; g <= max; g++) {
            for (var a = g; a <= max; a += g) {
                Map[a][g] = 0;
                ops1++;
            }
        }

        var ops2 = 0;
        for (var g = 2; g <= max; g++) {
            var counter = Map[g];
            counter[g] = max / g;

            var divs = counter.Dict.Keys.ToArray();
            Array.Sort(divs, 0, divs.Length);

            for (var i = divs.Length - 2; i >= 0; i--) {
                var cnt = max / divs[i];
                for (var j = i + 1; j < divs.Length; j++) {
                    if (divs[j] % divs[i] == 0)
                        cnt -= counter[divs[j]];
                }
                counter[divs[i]] = cnt;
            }

            ops2 += divs.Length * divs.Length;
        }

        if (max == 100) {
            for (var g = 1; g <= max; g++) {
                System.Console.WriteLine(new {g});
                foreach (var kvp in Map[g].Dict)
                    System.Console.WriteLine("   " + new { gcd=kvp.Key, cnt=kvp.Value });
            }
        }

        System.Console.WriteLine(new {max, ops1, ops2});

        return Map;
    }

    static Counter<int>[] GetGcdsCounter_Brute(int max) {
        var Map = Helpers.CreateArray(max + 1, _ => new Counter<int>());
        for (var g = 1; g <= max; g++) {
            for (var x = 1; x <= max; x++) {
                var gcd = (int)GCD((ulong)g, (ulong)x);
                if (gcd > 1)
                    Map[g][gcd]++;
            }
            if (max == 100) {
                System.Console.WriteLine(new {g});
                foreach (var kvp in Map[g].Dict)
                    System.Console.WriteLine("   " + new { gcd=kvp.Key, cnt=kvp.Value });
            }
        }
        return Map;
    }

    private static ulong GCD(ulong a, ulong b) {
        while (a != 0 && b != 0) {
            if (a > b)
                a %= b;
            else
                b %= a;
        }
        return a == 0 ? b : a;
    }

    static void Compare(Counter<int>[] A, Counter<int>[] B) {
        for (var i = 0; i < A.Length; i++) {
            var C = A[i].Dict;
            var D = B[i].Dict;
            if (C.Count != D.Count) {
                System.Console.WriteLine(new { i, ccount = C.Count, dcount = D.Count });
                return;
            }
            if (!C.Keys.OrderBy(c => c).SequenceEqual(D.Keys.OrderBy(c => c))) {
                System.Console.WriteLine(new { i, ckeys=C.Keys.OrderBy(c => c).Join(), dkeys=D.Keys.OrderBy(c => c).Join() });
                return;
            }
            foreach (var key in C.Keys) {
                if (C[key] != D[key]) {
                    System.Console.WriteLine(new { i, ckeys=C.Keys.OrderBy(c => c).Join(), dkeys=D.Keys.OrderBy(c => c).Join() });
                    System.Console.WriteLine(new { key, cval=C[key], dval=D[key] });
                }
            }
        }
        System.Console.WriteLine("compare ok");
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public class Counter<T> {
    public Dictionary<T, int> Dict;
    public Counter() { Dict = new Dictionary<T, int>(); }
    public Counter(IEnumerable<T> keys) { Dict = new Dictionary<T, int>(); foreach (var k in keys) Add(k, 1); }
    public int this[T key] {
        get { int res; return Dict.TryGetValue(key, out res) ? res : 0; }
        set { Dict[key] = value; }
    }
    public void Add(T key, int add) { int res; if (Dict.TryGetValue(key, out res)) Dict[key] = res + add; else Dict[key] = add; }
}

public static class Helpers {
    public static string Join<T>(this IEnumerable<T> arr, string sep = " ") {
        return string.Join(sep, arr);
    }

    public static void Swap<T>(ref T a, ref T b) {
        var tmp = a;
        a = b;
        b = tmp;
    }

    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public 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 ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + 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;
    }

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


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace ReadWriteTemplate
{
    public static class Solver
    {
        public const long MOD = 1000000000 + 7;

        private static List<int> Primes;

        private static void SolveCase()
        {
            int m = ReadInt();

            Primes = GetPrimes(m);

            Frac[] f = new Frac[m + 1];
            f[1] = new Frac(0, 1);

            var p = new List<Pair>[m + 1];
            for (int i = 2; i <= m; i++)
            {
                p[i] = new List<Pair>();
                bool found = false;
                for (int j = 0; j < Primes.Count && Primes[j] * Primes[j] <= i; j++)
                {
                    if (i % Primes[j] == 0)
                    {
                        bool inc = false;
                        int d = i / Primes[j];
                        for (int k = 0; k < p[d].Count; k++)
                        {
                            Pair pair = new Pair(p[d][k].A, p[d][k].B);
                            if (p[d][k].A == Primes[j])
                            {
                                pair.B++;
                                inc = true;
                            }
                            p[i].Add(pair);
                        }
                        if (!inc)
                        {
                            p[i].Add(new Pair(Primes[j], 1));
                        }
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    p[i].Add(new Pair(i, 1));
                }

                var pairs = new List<Pair>();
                Build(m, p[i], 0, i, 0, new int[10], pairs);

                int eqk = 0;
                var pr = new Frac(m, 1);
                for (int j = 0; j < pairs.Count; j++)
                {
                    var pair = pairs[j];
                    if (pair.A != i)
                    {
                        var c = new Frac(f[pair.A].X * pair.B % MOD, f[pair.A].Y);
                        pr = Sum(pr, c);
                    }
                    else
                    {
                        eqk += pair.B;
                    }
                }

                pr.Y = pr.Y * (m - eqk) % MOD;

                f[i] = pr;
            }

            Frac sum = new Frac(m, 1);
            for (int i = 0; i < m; i++)
            {
                sum = Sum(sum, f[i + 1]);
            }

            long ans = sum.X * BinPower(sum.Y, MOD - 2, MOD) % MOD * BinPower(m, MOD - 2, MOD) % MOD;

            Writer.WriteLine(ans);
        }

        private static Frac Sum(Frac a, Frac b)
        {
            return new Frac((a.X * b.Y + a.Y * b.X) % MOD, (a.Y * b.Y) % MOD);
        }

        private static void Build(int m, List<Pair> p, int t, int d, int q, int[] div, List<Pair> pairs)
        {
            if (t >= p.Count)
            {
                int count = Calc(m / d, 0, q, div, 0);
                pairs.Add(new Pair(d, count));
                return;
            }

            Build(m, p, t + 1, d, q, div, pairs);
            div[q] = p[t].A;
            for (int i = 1; i <= p[t].B; i++)
            {
                d /= p[t].A;
                Build(m, p, t + 1, d, q + 1, div, pairs);
            }
        }

        private static int Calc(int x, int t, int q, int[] div, int c)
        {
            if (t >= q)
            {
                return (((div.Length + c) & 1) == 0 ? 1 : -1) * x;
            }

            return Calc(x, t + 1, q, div, c) +
                   Calc(x / div[t], t + 1, q, div, c + 1);
        }

        public static long BinPower(long a, long n, long mod)
        {
            long result = 1;

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result = (result * a) % mod;
                }

                a = (a * a) % mod;
                n >>= 1;
            }

            return result;
        }

        public class Pair
        {
            public Pair(int a, int b)
            {
                A = a;
                B = b;
            }

            public int A;

            public int B;

            public override string ToString()
            {
                return $"({A}, {B})";
            }
        }

        public class Frac
        {
            public Frac(long x, long y)
            {
                X = x;
                Y = y;
            }

            public long X;

            public long Y;

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

        public static List<int> GetPrimes(long n)
        {
            var primes = new List<int>();

            n = Math.Max(n, 2);
            bool[] isPrime = new bool[n + 1];
            for (int i = 2; i <= n; i++)
            {
                isPrime[i] = true;
            }

            for (int i = 2; i <= n; i++)
            {
                if (isPrime[i])
                {
                    primes.Add(i);
                    if ((long)i * i <= n)
                    {
                        for (int j = i * i; j <= n; j += i)
                        {
                            isPrime[j] = false;
                        }
                    }
                }
            }

            return primes;
        }

        public static void Solve()
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif

            SolveCase();

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                // Writer.WriteLine("Case {0}:", i + 1);
                // Writer.Write("Case #{0}: ", i + 1);
                SolveCase();
            }*/

#if DEBUG
            sw.Stop();
            Console.WriteLine($"{sw.ElapsedMilliseconds} ms");
#endif
        }

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

#if DEBUG
            // Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            // Solve();
            Thread thread = new Thread(Solve, 64 * 1024 * 1024);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Random rnd = new Random();
            for (int i = result.Length - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = result[k];
                result[k] = result[i];
                result[i] = tmp;
            }
            return result;
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        private static Queue<string> CurrentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (CurrentLineTokens.Count == 0)
                CurrentLineTokens = new Queue<string>(ReadAndSplitLine());
            return CurrentLineTokens.Dequeue();
        }

        public static string ReadLine()
        {
            return Reader.ReadLine();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadIntArray();
            return matrix;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++)
                lines[i] = Reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            Writer.WriteLine(string.Join(" ", array));
        }

        #endregion
    }
}


using System;
using System.Linq;

namespace CF1514B
{
    class Program
    {
        static void Main(string[] args)
        {
            int T = int.Parse(Console.ReadLine());

            for (int t = 0; t < T; t++)
            {
                long[] nk = Console.ReadLine().Split(" ").Select(long.Parse).ToArray();
                long ans = 1;
                for (int i = 0; i < nk[1]; i++)
                {
                    ans = (ans * nk[0]) % 1000000007;
                }
                Console.WriteLine(ans);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
   using System.Net.Sockets;
   using System.Numerics;

namespace Task
{
  static class Program
  {
    #region Read / Write
    static TextReader Reader;
    static TextWriter Writer;
    private static Queue<string> _currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return Reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (_currentLineTokens.Count == 0) _currentLineTokens = new Queue<string>(ReadAndSplitLine()); return _currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
      int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
      for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }
      return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = Reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { Writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array) Writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
      public new TValue this[TKey key]
      {
        get { return ContainsKey(key) ? base[key] : default(TValue); }
        set { base[key] = value; }
      }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }
    #endregion=

    public static bool NextPermutation(List<int> perm)
    {
      for (int i = perm.Count - 2; i >= 0; i--)
      {
        if (perm[i] < perm[i + 1])
        {
          int min = i + 1;
          for (int j = min; j < perm.Count; j++)
            if (perm[j] > perm[i] && perm[j] < perm[min])
              min = j;

          var tmp = perm[i];
          perm[i] = perm[min];
          perm[min] = tmp;
          perm.Reverse(i + 1, perm.Count - i - 1);
          return true;
        }
      }

      return false;
    }

    #region SegmentTree

    public static long SegmentTreeFunc(long a, long b)
    {
      return a + b;
    }

    public static void Build(long[] a, long v, long tl, long tr)
    {
      if (tl == tr)
        t[v] = a[tl];
      else
      {
        long tm = (tl + tr) / 2;
        Build(a, v * 2, tl, tm);
        Build(a, v * 2 + 1, tm + 1, tr);
        t[v] = SegmentTreeFunc(t[v * 2], t[v * 2 + 1]);
      }
    }

    public static long Query(long v, long tl, long tr, long l, long r)
    {
      if (l > r)
        return 0;
      if (l == tl && r == tr)
        return t[v];

      var tm = (tl + tr) / 2;
      var res = SegmentTreeFunc(Query(v * 2, tl, tm, l, Math.Min(r, tm)), Query(v * 2 + 1, tm + 1, tr, Math.Max(l, tm + 1), r));
      return res;
    }

    public static long[] t;

    #endregion

    private static readonly int modulus = 1000000007;
    // private static readonly int modulus1 = modulus - 1;

    public static long Pow(long a, long b)
    {
      long y = 1;

      while (true)
      {
        if ((b & 1) != 0)
          y = a * y % modulus;
        b = b >> 1;
        if (b == 0)
          return y;
        a = a * a % modulus;
      }
    }

    public static long ReversedNumbByPrimeModulo(long a)
    {
      return Pow(a, modulus - 2);
    }

    public static long FactByModulo(long a)
    {
      long ans = 1;

      while (a > 0)
      {
        ans = ans * a % modulus;
        a--;
      }

      return ans;
    }

    public static long nCkModulo(long n, long k)
    {
      if (k < n >> 1)
        k = n - k;

      long ans = 1;
      for (long i = n; i > k; i--)
        ans = ans * i % modulus;

      k = n - k;
      var fact = FactByModulo(k);
      var revFact = ReversedNumbByPrimeModulo(fact);

      ans = ans * revFact % modulus;

      return ans;
    }

    // public static int maxForPrimeCalc = 30000000;
    // public static List<int> primes = new List<int>(maxForPrimeCalc) {2};
    // public static int[] minPrimeDiv = new int[maxForPrimeCalc + 1];
    // public static bool[] isPrime = new bool[maxForPrimeCalc + 1];
    //
    // public static void CalcPrimes()
    // {
    //   isPrime[2] = true;
    //   for (var i = 2; i <= maxForPrimeCalc; i += 2)
    //   {
    //     isPrime[i] = false;
    //     minPrimeDiv[i] = 2;
    //   }
    //   for (var i = 3; i <= maxForPrimeCalc; i += 2)
    //   {
    //     isPrime[i] = true;
    //   }
    //
    //   for (var i = 3; i * i <= maxForPrimeCalc; i += 2)
    //   {
    //     if (isPrime[i])
    //     {
    //       minPrimeDiv[i] = i;
    //       primes.Add(i);
    //       for (var j = i * i; j <= maxForPrimeCalc; j += i)
    //       {
    //         if (isPrime[j])
    //         {
    //           isPrime[j] = false;
    //           minPrimeDiv[j] = i;
    //         }
    //       }
    //     }
    //   }
    // }
    //
    // public static int[] PrimeDifferentDividersCountHash = new int[maxForPrimeCalc + 1];
    //
    // private static int PrimeDifferentDividersCount(long numb)
    // {
    //   if (numb == 1)
    //     return 0;
    //   if (isPrime[numb])
    //     return 1;
    //
    //   if (PrimeDifferentDividersCountHash[numb] > 0)
    //     return PrimeDifferentDividersCountHash[numb];
    //
    //   var divider = minPrimeDiv[numb];
    //   var prevNumb = numb / divider;
    //   var ans = PrimeDifferentDividersCount(prevNumb);
    //
    //   if (divider != minPrimeDiv[prevNumb])
    //   {
    //     ans += 1;
    //   }
    //
    //   PrimeDifferentDividersCountHash[numb] = ans;
    //
    //   return ans;
    // }

    #region Heap

    public static void InsertElementInHeap(int value, int[] arr, ref int sizeOfTree)
    {
        arr[sizeOfTree + 1] = value;
        sizeOfTree++;
        HeapifyBottomToTop(sizeOfTree, arr);
    }

    public static void HeapifyBottomToTop(int index, int[] arr)
    {
      int parent = index / 2;
      // We are at root of the tree. Hence no more Heapifying is required.
      if (index <= 1) {
        return;
      }
      // If Current value is smaller than its parent, then we need to swap
      if (arr[index] > arr[parent]) {
        int tmp = arr[index];
        arr[index] = arr[parent];
        arr[parent] = tmp;
      }
      HeapifyBottomToTop(parent, arr);
    }

    public static int ExtractHeadOfHeap(ref int sizeOfTree, int[] arr) {
      if(sizeOfTree == 0) {
        return -1;
      }else {
        int extractedValue = arr[1];
        arr[1] = arr[sizeOfTree]; //Replacing with last element of the array
        sizeOfTree--;
        HeapifyTopToBottom(1, sizeOfTree, arr);
        return extractedValue;
      }
    }

    public static void HeapifyTopToBottom(int index, int sizeOfTree, int[] arr)
    {
      int left  = index << 1;
      int right = left + 1;
      int smallestChild = 0;

      if (sizeOfTree < left) { //If there is no child of this node, then nothing to do. Just return.
        return;
      }else if (sizeOfTree == left) { //If there is only left child of this node, then do a comparison and return.
        if(arr[index] < arr[left]) {
          int tmp = arr[index];
          arr[index] = arr[left];
          arr[left] = tmp;
        }
        return;
      }else { //If both children are there
        if(arr[left] > arr[right]) { //Find out the smallest child
          smallestChild = left;
        }else {
          smallestChild = right;
        }
        if(arr[index] < arr[smallestChild]) { //If Parent is greater than smallest child, then swap
          int tmp = arr[index];
          arr[index] = arr[smallestChild];
          arr[smallestChild] = tmp;
        }
      }
      HeapifyTopToBottom(smallestChild, sizeOfTree, arr);
    }

    #endregion

    static long GCD(long a, long b)
    {
      while (b > 0) {
        a %= b;
        a ^= b;
        b ^= a;
        a ^= b;
      }
      return a;
    }

    private static int mod = 1000000007;

    static void Main(string[] args)
    {
      Reader = new StreamReader(Console.OpenStandardInput());
      Writer = new StreamWriter(Console.OpenStandardOutput());

      //CalcPrimes();

      var t = ReadInt();
      for (var tmp = 0; tmp < t; tmp++)
      {
        Solve();
      }

      Reader.Close();
      Writer.Close();
    }

    static void Solve()
    {
      var n = ReadInt();
      var k = ReadInt();

      var mod = 1000000007;
      if (n == 1)
      {
        Write(1);
      }
      else
      {
        var ans = Pow(n, k);
        Write(ans);
      }
    }

    private static void BFS(List<int>[] g, int curV, int[] curColors, int[] c, HashSet<int> visited, List<int> ans)
    {
      if (curColors[c[curV - 1]] == 0)
        ans.Add(curV);

      visited.Add(curV);
      curColors[c[curV - 1]]++;
      foreach (var neigh in g[curV])
      {
        if (!visited.Contains(neigh))
        {
          BFS(g, neigh, curColors, c, visited, ans);
        }
      }
      curColors[c[curV - 1]]--;
    }

    private static long GetNumb(Dictionary<char, int> letterDic, List<int> permutation, string s)
    {
      long res = 0;
      long mult = 1;
      for (var i = s.Length - 1; i >= 0; i--)
      {
        res += permutation[letterDic[s[i]]] * mult;

        mult *= 10;
      }

      return res;
    }

    public class MyStruct
    {
      public int Index;
      public int Weight;
      public int Value;

      public MyStruct(int index, int weight, int value)
      {
        Index = index;
        Weight = weight;
        Value = value;
      }
    }

    static void Inc(this Dictionary<long, long> dict, long key, long addedValue)
    {
      if (dict.ContainsKey(key))
        dict[key] += addedValue;
      else
        dict[key] = addedValue;
    }

    static void Inc(this Dictionary<int, int> dict, int key, int addedValue)
    {
      if (dict.ContainsKey(key))
        dict[key] += addedValue;
      else
        dict[key] = addedValue;
    }
  }
}


using System;
using System.Collections.Generic;

namespace CCS
{
    class Program
    {
        static List<int> s = new List<int>();

        static bool Rec(int a, int b)
        {
            if (a == b)
            {
                s.Add(b);
                return true;
            }
            else if (b > a)
            {
                bool w = false;

                if (b % 2 == 0)
                {
                    w = Rec(a, b / 2);
                    if (w)
                        s.Add(b);
                    return w;
                }
                if ((b - 1) % 10 == 0)
                {
                    w = Rec(a, (b - 1) / 10);
                    if (w)
                        s.Add(b);
                    return w;
                }
                return false;
            }
            return false;
        }

        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            if (Rec(int.Parse(input[0]), int.Parse(input[1])))
            {
                Console.WriteLine("YES");
                Console.WriteLine(s.Count.ToString());
                for (int i = 0; i < s.Count; i++)
                    Console.Write(s[i] + " ");
                return;
            }
            Console.Write("NO");
        }
    }
}


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

namespace cf727A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int a = ab[0]; int b = ab[1];

            List<int> operations = new List<int>();

            while(b > a)
            {
                operations.Add(b);
                if ((b % 2) == 0)
                    b /= 2;
                else if (b.ToString().EndsWith("1"))
                {
                    b = (b - 1) / 10;
                }
                else
                {
                    Console.WriteLine("NO"); return;
                }
            }

            if (b == a)
            {
                Console.WriteLine("YES");
                Console.WriteLine(operations.Count + 1);
                Console.Write(a); Console.Write(' ');
                for (int i = 1; i <= operations.Count; i++)
                {
                    Console.Write(operations[operations.Count-i]); Console.Write(' ');
                }
            }
            else Console.WriteLine("NO");
        }
    }
}


using System;

class Program
{
    static void Main(string[] args)
    {
        var inp = Console.ReadLine().Split(' ');
        long t = long.Parse(inp[0]);
        long n = long.Parse(inp[1]);
        long r = 0;
        if (t >= 2 * n + 1)
            r = n * t + (t - 2 * n) * n - n;
        else
            r = t * (t - 1) / 2;
        Console.WriteLine(r);
        Console.ReadLine();
    }
}


#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

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

namespace KRO2
{
	class Program
	{
		static string _inputFilename = "input.txt";
		static string _outputFilename = "output.txt";
#if DEBUG
        static bool _useFileInput = false;
#else
		static bool _useFileInput = false;
#endif

		static void Main(string[] args)
		{
			StreamWriter file = null;
			if (_useFileInput)
			{
				Console.SetIn(File.OpenText(_inputFilename));
				file = new StreamWriter(_outputFilename);
				Console.SetOut(file);
			}

#if DEBUG
			if (!_useFileInput)
			{
				Console.SetIn(getInput());
			}
#endif

			try
			{
				solution();
			}
			finally
			{
				if (_useFileInput)
				{
					file.Close();
				}
			}
		}

		static void solution()
		{
			#region SOLUTION
			var d = readIntArray();
			var n = d[0];
			var k = d[1];

			if (n / 2 <= k)
			{
				var val = 0L;
				for (int i = 1; i <= n; i++)
				{
					val += n - (i);
				}

				Console.WriteLine(val);
			}
			else
			{
				var res = 0L;
				for (int i = 1; i <= n; i++)
				{
					if (i <= k || i >= n - k + 1)
					{
						res += n - i;
					}
					else
					{
						res += k;
					}
				}
				Console.WriteLine(res);
			}

			//var n = readInt();
			//var m = readInt();

			//var a = readIntArray();
			//var b = readIntArray();
			#endregion
		}

		static int readInt()
		{
			return int.Parse(Console.ReadLine());
		}

		static long readLong()
		{
			return long.Parse(Console.ReadLine());
		}

		static int[] readIntArray()
		{
			return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
		}

		static long[] readLongArray()
		{
			return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
		}

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
	}
}


using System;

public class Chocolate
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] temp_nuts = Console.ReadLine().Split(' ');
        int[] nuts = Array.ConvertAll(temp_nuts, int.Parse);
        long answer = 1;
        int foundNut = -1;

        for (int x = 0; x < n; x++){
            if (nuts[x] == 1){
                if (foundNut != -1){
                    answer *= (x - foundNut);
                }
                foundNut = x;
            }
        }
        if (foundNut == -1){
            Console.WriteLine(0);
        }
        else{
            Console.WriteLine(answer);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
public class GFG
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        long result = 0;
        int prev = -1;

        for (int i = 0; i < n; i++)
        {
            if (arr[i] == 1)
            {
                if (prev == -1)
                {
                    result = 1;
                }
                else
                {
                    result *= i - prev;
                }
                prev = i;
            }

        }

        Console.Write(result);

    }

}


using System;
using System.IO;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

class Program
{

    //////////////////////////////////////////////////
    void Solution()
    {
        var l1 = rl;
        var r1 = rl;
        var l2 = rl;
        var r2 = rl;
        var k = rl;

        if (r2 < l1)
        {
            wln(0);
            return;
        }

        if (r1 < l2)
        {
            wln(0);
            return;
        }

        var ml = Math.Max(l1, l2);
        var mr = Math.Min(r1, r2);
        if (mr < ml)
        {
            wln(0);
            return;
        }
        var ans = mr - ml + 1;
        if (k >= ml && k <= mr)
            ans--;

        wln(ans);
    }
    //////////////////////////////////////////////////

    static void swap<T>(ref T o1, ref T o2) { var o = o1; o1 = o2; o2 = o; }

    static void wln() { Console.WriteLine(); }
    static void wln<T>(T o) { Console.WriteLine(o); }
    static void wsp<T>(T o) { Console.Write(o + " "); }
    static void wrt<T>(T o) { Console.Write(o); }

    static void wln(double o) { Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }
    static void wsp(double o) { Console.Write(string.Format(CultureInfo.InvariantCulture, "{0:F12} ", o)); }
    static void wrt(double o) { Console.Write(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }

    static long gcd(long a, long b) { return (b != 0) ? gcd(b, a % b) : a; }
    static long lcm(long a, long b) { return a / gcd(a, b) * b; }

    int ri
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            int p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    long rl
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    double rd
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';
            if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;
        }
    }
    string rs
    {
        get
        {
            _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;
            var tmp = _str.IndexOf(' ', _ind);
            if (tmp == -1) { _count = 0; _ind = 0; return _str.Substring(_ind); }
            var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;
        }
    }

    int[] ria(int n)
    {
        var res = new int[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    long[] rla(int n)
    {
        var res = new long[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    double[] rda(int n)
    {
        var res = new double[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';
                if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }
                res[k++] = (double)p / q * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    string[] rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res; }
    string _str = null; int _count = 0; int _ind = 0;
    void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }
    static void Main() { new Program().Solution(); }
}


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

namespace CodeforcesTasks
{
    class Program_371A
    {
        static void Main()
        {
            string[] inStr = Console.ReadLine().Split(' ');
            long l1 = long.Parse(inStr[0]);
            long r1 = long.Parse(inStr[1]);
            long l2 = long.Parse(inStr[2]);
            long r2 = long.Parse(inStr[3]);
            long k = long.Parse(inStr[4]);
            long beg, end, dur;

            if (l1 >= l2)
            {
                beg = l1;
            }
            else
            {
                beg = l2;
            }
            if (r1 >= r2)
            {
                end = r2;
            }
            else
            {
                end = r1;
            }
            if (end < beg)
            {
                dur = 0;
            }
            else
            {
                dur = end - beg + 1;
            }
            if ( (dur > 0) && (k >= beg) && (k <= end) )
            {
                dur = dur - 1;
            }
            Console.WriteLine(dur);
        }
    }
}


using System; using System.Linq;

class P {
  static void Main() {
    var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    if (a[1] - a[0] == a[2] - a[1] && a[2]-a[1] == a[3] - a[2]){
      Console.Write(a[3] + a[2] - a[1]); return;
    }
    if (a[2]*a[0] == a[1]*a[1] && a[2]*a[2] == a[3]*a[1]) {
       var d = a[3]*a[3];
       if (d % a[2] == 0) {
       Console.Write(d/a[2]); return; }
    }
    Console.Write(42);
  }
}


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

namespace CodeForces
{
    class R191_Test8_A
    {
        static void Main(string[] args)
        {
            int n = 4;
            string[] s = Console.ReadLine().Split();
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = int.Parse(s[i]);

            if (a[3] - a[2] == a[2] - a[1]
             && a[2] - a[1] == a[1] - a[0])
            {
                int d = a[1] - a[0];
                Console.WriteLine(a[3] + d);
                return;
            }

            if (a[3] * a[1] == a[2] * a[2]
             && a[2] * a[0] == a[1] * a[1])
            {
                double q = a[3] * a[3] / (double)a[2];
                if (Math.Abs(q - (int)q) < 0.0001)
                {
                    Console.WriteLine(a[3] * a[3] / (double)a[2]);
                    return;
                }
            }

            Console.WriteLine(42);
        }
    }
}


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

namespace ConsoleApplication1
{
    public class Program
    {
        public static void Main()
        {
            string[] lines = new string[8];
            string ans = "YES";

            for (int i = 0; i < 8; ++i)
                lines[i] = Console.ReadLine();

            for(int i = 0; i < 8; ++i)
                for (int j = 0; j < 7; ++j)
                {
                    if (lines[i][j] == lines[i][j + 1])
                    {
                        ans = "NO";
                        i = 8;
                        break;
                    }
                }

            Console.WriteLine(ans);
        }
    }
}


using System;
namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i < 8; i++)
            {
                char prevChar = (char)Console.Read();
                for (int j = 1; j < 8; j++)
                {
                    char ch = (char)Console.Read();
                    if (ch == prevChar)
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                    prevChar = ch;
                }
                Console.ReadLine();
            }
            Console.WriteLine("YES");
        }
    }
}


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

namespace ConsoleApplication34
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            var nums = Console.ReadLine().Split().Select(e => Convert.ToInt32(e)).ToArray();

            for (int i = 0; i < 100; i++)
            {
                Array.Sort(nums);
                for (int j = nums.Length-1; j >0&& nums[j] > 1; j--)
                    nums[j] = nums[j] > nums[j-1] ? nums[j] - nums[j-1] : nums[j];

            }

            Console.WriteLine(nums.Sum());
            Console.ReadLine();
        }
    }
}


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

namespace Codeforces
{
    class Program
    {
        public static int NOD(int a, int b)
        {
            int x;

            if (a > b)
            {
                x = a;
                a = b;
                b = x;
            }

            while (a > 0)
            {
                x = a;
                a = b % a;
                b = x;
            }

            return b;
        }

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = int.Parse(s);

            string[] ss = Console.ReadLine().Split();
            int[] a = new int[n];

            int x = int.Parse(ss[0]);

            for (int i = 0; i < n; i++)
                a[i] = int.Parse(ss[i]);

            int k = a[0];

            for (int i = 0; i < n; i++)
                for (int j = i + 1; j < n; j++)
                {
                    k = Math.Min(k, NOD(a[i], a[j]));
                    if (k == 1)
                    {
                        Console.WriteLine(n);
                        return;
                    }
                }

            for (int i = 0; i < n; i++)
                k = Math.Min(k, NOD(a[i], k));

            Console.WriteLine(k * n);
        }
    }
}


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

namespace Codeforces
{
    class Program
    {
        static StreamReader reader;
        static StreamWriter writer;
        static Random rand = new Random(0);

        static void Main(string[] args)
        {
            //#if DEBUG
            reader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);
            writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);
            //#else
            //            StreamReader streamReader = new StreamReader(Console.OpenStandardInput(32768), Encoding.ASCII, false, 32768);
            //            StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(32768), Encoding.ASCII, 32768);
            //#endif
            InputReader input = new InputReader(reader);

            long n = input.NextLong();
            bool ok = false;
            for (long a = 0; a < 820; a++)
            {
                for (long b = 0; b < 8200; b++)
                {
                    long mul = a * 1234567L + b * 123456L;
                    if (mul <= n)
                    {
                        ok |= ((n - mul) % 1234 == 0);
                    }
                }
            }
            writer.WriteLine(ok ? "YES" : "NO");

#if DEBUG
                Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
#endif
            writer.Flush();
            writer.Close();
            reader.Close();
        }
    }

    class MyInt
    {
        public int data;

    }

    class MyPair
    {
        public int x, y;

        public MyPair(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }

    // this class is copy
    class InputReader
    {
        private char[] _inbuf;
        private int _lenbuf = 0, _ptrbuf = 0;
        private StreamReader _reader;

        public InputReader(StreamReader reader)
        {
            _reader = reader;
            _inbuf = new char[1024];
            _lenbuf = 0;
            _ptrbuf = 0;
        }

        private int ReadByte()
        {
            if (_lenbuf == -1)
                throw new Exception();
            if (_ptrbuf >= _lenbuf)
            {
                _ptrbuf = 0;
                try
                {
                    _lenbuf = _reader.Read(_inbuf, 0, 1024);
                }
                catch (IOException e)
                {
                    throw e;
                }
                if (_lenbuf <= 0)
                    return -1;
            }
            return _inbuf[_ptrbuf++];
        }

        private bool IsSpaceChar(int c)
        {
            return !(c >= 33 && c <= 126);
        }

        private int Skip()
        {
            int b;
            while ((b = ReadByte()) != -1 && IsSpaceChar(b)) ;
            return b;
        }

        public int NextInt()
        {
            return int.Parse(this.Next());
        }

        public int[] NextIntArray(int n)
        {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = NextInt();
            }
            return a;
        }

        public long NextLong()
        {
            return long.Parse(this.Next());
        }

        public string Next()
        {
            var b = Skip();
            var sb = new StringBuilder();
            while (!(IsSpaceChar(b)))
            {
                sb.Append((char)b);
                b = ReadByte();
            }
            return sb.ToString();
        }

        public double NextDouble()
        {
            return double.Parse(Next(), CultureInfo.InvariantCulture);
        }

        internal long[] NextLongArray(long n)
        {
            long[] a = new long[(int)n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = NextLong();
            }
            return a;
        }

        internal double[] NextDoubleArray(int n)
        {
            double[] a = new double[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = NextDouble();
            }
            return a;
        }
    }
}


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

namespace B.Экономическая_игра
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            bool pr = false;
            //int i, j, k = 0;

            //for (i = 0; i * 1234567 <= n; i++)
            //{
            //    for (j = 0; j * 123456 <= n - i * 1234567; j++)
            //    {
            //        for (k = 0; k * 1234 <= n - i * 1234567 - j * 123456; k++)
            //        {
            //            if (n - i * 1234567 - j * 123456 - k * 1234 == 0)
            //            {
            //                pr = true;
            //                break;
            //            }
            //        }
            //    }

            //}

            for (int i = n / 1234567; i >= 0; i--)
            {
                for (int j = (n - 1234567 * i) / 123456; j >= 0; j--)
                {
                        if ((n - i * 1234567 - j * 123456) % 1234 == 0)
                        {
                            pr = true;
                            break;
                    }
                }

            }

            if (pr) Console.WriteLine("YES");
            else Console.WriteLine("NO");

            Console.ReadLine();

        }
    }
}


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

namespace Compete.CFE38 {
    public class TaskA {
        public static void Main(string[] args) {
            new TaskA().Solve(Console.In, Console.Out);
        }

        public void Solve(TextReader input, TextWriter output) {
            // INPUT
            var n = int.Parse(input.ReadLine());
            var s = input.ReadLine();

            // SOLUTION
            var sb = new StringBuilder();
            bool prev = false;
            foreach (var c in s) {
                if (IsVowel(c)) {
                    if (!prev) {
                        prev = true;
                        sb.Append(c);
                    }
                }
                else {
                    prev = false;
                    sb.Append(c);
                }
            }

            // OUTPUT
            output.WriteLine(sb.ToString());
        }

        private static bool IsVowel(char c) { return "aeiouy".Contains(c); }
    }
}


using System;

namespace Буквы
{
    class Program
    {
        static void Main(string[] args)
        {
            string G = "aouiey";

            bool Flag = false;
            int N = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < N; i++)
            {
                char c = (char)Console.Read();
                if (G.Contains(c.ToString()) == false)
                {
                    Flag = false;
                    Console.Write(c);
                }
                else//(G.Contains(c) == true)
                {
                    if (Flag==false)
                    {
                        Console.Write(c);

                    }
                    Flag = true;
                }

            }
            Console.WriteLine();
        }
    }
}


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

namespace Odds_and_Ends
{
    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)
        {
            int n = Next();

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next()%2;
            }

            if (nn[0] == 0 || n%2 == 0)
            {
                writer.WriteLine("No");
                writer.Flush();
                return;
            }

            if (!Solve(nn, n))
            {
                Array.Reverse(nn);
                if (nn[0] == 0)
                {
                    writer.WriteLine("No");
                    writer.Flush();
                    return;
                }

                writer.WriteLine(!Solve(nn, n) ? "No" : "Yes");
            }
            else writer.WriteLine("Yes");

            writer.Flush();
        }

        private static bool Solve(int[] nn, int n)
        {
            int cross = 0;
            int g = 0;
            for (int i = 0; i < n; i++)
            {
                if (nn[i] == 0)
                {
                    for (int j = i + 1; j < n; j++)
                    {
                        if (nn[j] == 1 && nn[j - 1] == 1 && (j - i)%2 == 0)
                        {
                            g++;
                            cross += j - i + 1;
                            i = j;
                            break;
                        }
                    }
                    if (nn[i] == 0)
                    {
                        if (nn[n - 1] == 1 && (n - i)%2 == 0)
                        {
                            g++;
                            cross += n - i + 1;
                            i = n;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }

            return (n - cross + g)%2 == 1;
        }

        private static int Next()
        {
            int c;
            int 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;
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(N % 2 == 0){
			Console.WriteLine("No");
			return;
		}
		if(A[0]%2 == 0 || A[N-1]%2 == 0){
			Console.WriteLine("No");
			return;
		}

		Console.WriteLine("Yes");
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	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;

namespace CSharp
{
    public class _748A
    {
        public static void Main()
        {
            string[] tokens = Console.ReadLine().Split();

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

            int r = (k + 2 * m - 1) / (2 * m);
            int d = (k + 1) / 2 - (r - 1) * m;
            char s = k % 2 == 0 ? 'R' : 'L';

            Console.WriteLine($"{r} {d} {s}");
        }
    }
}


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

namespace mo
{
    class Program
    {
        static void Main(string[] args)
        {
            var numbers = GetIntegerInputsFromLine();

            int i = 1;

            int lanes = numbers[1] * 2;

            while (lanes < numbers[2])
            {

                i++;

                lanes = numbers[1] * 2 * i;
            }

            var divider = ((i - 1) * numbers[1] * 2);

            var rows = numbers[2];

            if (divider != 0)
            {
                rows = rows % divider;
            }

            var f = 'R';

            if (rows == 0)
            {
                rows = numbers[1];
            }
            else if (rows % 2 == 1)
            {
                rows = rows / 2 + 1;

                f = 'L';
            }
            else
            {
                rows = rows / 2;
            }

            Console.WriteLine(i + " " + rows + ' ' + f);
        }

        static int GetIntegerInputFromLine()
        {
            var input = Convert.ToInt32(Console.ReadLine().Trim());
            return input;
        }

        static int[] GetIntegerInputsFromLine()
        {
            var inputs = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x.Trim())).ToArray();
            return inputs;
        }

        static long GetLongInputFromLine()
        {
            var input = Convert.ToInt64(Console.ReadLine().Trim());
            return input;
        }

        static long[] GetLongInputsFromLine()
        {
            var inputs = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x.Trim())).ToArray();
            return inputs;
        }

        static double GetDoubleInputFromLine()
        {
            var input = Convert.ToDouble(Console.ReadLine().Trim());
            return input;
        }

        static double[] GetDoubleInputsFromLine()
        {
            var inputs = Console.ReadLine().Split(' ').Select(x => Convert.ToDouble(x.Trim())).ToArray();
            return inputs;
        }

        static string GetStringInputFromLine()
        {
            var input = Console.ReadLine();
            return input;
        }

        static string[] GetStringInputsFromLine()
        {
            var inputs = Console.ReadLine().Split(' ');
            return inputs;
        }
    }
}


using System;
using CompLib.Util;

public class Program
{
    private int N, M;
    private int[] L;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        L = sc.IntArray();

        // Mステップ　ゲーム
        // リーダー i
        // A 順列

        // 次のA_i番目を指定して リーダーにする
        // リーダーになった順 Lが与えられる

        // Aを出力 or 存在しない -1

        bool[] used = new bool[N + 1];
        int[] a = new int[N];
        for (int i = 0; i < M - 1; i++)
        {
            int d = (L[i + 1] - L[i] + N) % N;
            if (d == 0) d = N;
            if (a[L[i] - 1] == 0)
            {
                if (used[d])
                {
                    Console.WriteLine("-1");
                    return;
                }

                used[d] = true;
                a[L[i] - 1] = d;
            }
            else
            {
                if (a[L[i] - 1] != d)
                {
                    Console.WriteLine("-1");
                    return;
                }
            }
        }

        int index = 1;
        for (int i = 0; i < N; i++)
        {
            if (a[i] == 0)
            {
                while (used[index])
                {
                    index++;
                }

                a[i] = index;
                used[index] = true;
            }
        }

        Console.WriteLine(string.Join(" ", a));
    }

    public static void Main(string[] args) => new Program().Solve();
}

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 = Console.ReadLine();
                while (s.Length == 0)
                {
                    s = Console.ReadLine();
                }

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

            return _line[_index++];
        }

        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.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    private static void Main(string[] args)
    {
        var n = RI();
        var m = RI();
        var a = RIA(m);

        var ans = new int[n + 1];
        for (int i = 0; i < m - 1; i++)
        {
            var d = a[i + 1] - a[i];
            if (d <= 0) d += n;

            if (ans[a[i]] != 0 && ans[a[i]] != d)
            {
                Console.Write(-1);
                return;
            }

            ans[a[i]] = d;
        }

        for (int i = 1; i <= n; i++)
            if (ans[i] == 0)
            {
                for (int j = 1; j <= n; j++)
                    if (!ans.Contains(j))
                    {
                        ans[i] = j;
                        break;
                    }
            }

        if (ans.Skip(1).Distinct().Count() != n)
        {
            Console.WriteLine(-1);
            return;
        }

        Console.WriteLine(string.Join(" ", ans.Skip(1)));

    }

    private const int Mod = 1000000000 + 7;

    #region Data Read

    private static long GCD(long a, long b)
    {
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }

    private static List<int>[] ReadTree(int n)
    {
        return ReadGraph(n, n - 1);
    }

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < g.Length; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }

    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }

    private static char[] ReadWord()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z') || (ans == '*'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char[] ReadStringLine()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans == 10 || ans == 13);

        List<char> s = new List<char>();

        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans != 10 && ans != 13 && ans != -1);

        return s.ToArray();
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }

    private static char ReadAnyOf(IEnumerable<char> allowed)
    {
        while (true)
        {
            char ans = (char)consoleReader.Read();
            if (allowed.Contains(ans))
                return ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(StringBuilder sb)
    {
        PushTestData(sb.ToString());
    }
    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
    #endregion
}


using System;
using System.Linq;

namespace CSharp
{
    class _236B
    {
        public static void Main()
        {
            const int Mod = 1073741824;

            var tokens = Console.ReadLine().Split();

            int a = int.Parse(tokens[0]);
            int b = int.Parse(tokens[1]);
            int c = int.Parse(tokens[2]);

            int Max = a * b * c;

            var isPrime = new bool[Max + 1];
            for (int i = 2; i <= Max; i++)
            {
                isPrime[i] = true;
            }

            for (int i = 2; i <= Max; i++)
            {
                if (isPrime[i])
                {
                    for (int j = 2 * i; j <= Max; j += i)
                    {
                        isPrime[j] = false;
                    }
                }
            }

            var primes = Enumerable.Range(1, Max).Where(i => isPrime[i]).ToList();

            var d = new int[Max + 1];
            for (int i = 1; i <= Max; i++)
            {
                if (i == 1)
                {
                    d[i] = 1;
                }
                else if (isPrime[i])
                {
                    d[i] = 2;
                    continue;
                }
                else
                {
                    int prime = primes.First(p => i % p == 0);

                    int x = i;
                    int count = 0;

                    while (x % prime == 0)
                    {
                        x /= prime;
                        count++;
                    }

                    d[i] = d[x] * (count + 1);
                }
            }

            int sum = 0;

            for (int i = 1; i <= a; i++)
            {
                for (int j = 1; j <= b; j++)
                {
                    for (int k = 1; k <= c; k++)
                    {
                        sum = (sum + d[i * j * k]) % Mod;
                    }
                }
            }

            Console.WriteLine(sum);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

public class taskB
{
    public class MyReader
    {
        private TextReader instream;

        public int[] ReadIntArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            int[] a = new int[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = int.Parse(spl[i]);
            return a;
        }

        public double[] ReadDoubleArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            double[] a = new double[spl.Length];

            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            for (int i = 0; i < a.Length; i++)
                a[i] = double.Parse(spl[i], nfi);
            return a;
        }

        public int ReadInt()
        {
            return int.Parse(instream.ReadLine());
        }

        public long ReadLong()
        {
            return long.Parse(instream.ReadLine());
        }

        public void SetInStream(TextReader textReader)
        {
            this.instream = textReader;
        }

        internal string ReadLine()
        {
            return instream.ReadLine();
        }
    }

    static void Main(string[] args)
    {
        MyReader instream = new MyReader();
        instream.SetInStream(Console.In);

        TextWriter outstream = Console.Out;

        solve(instream, outstream);

    }

    static long MODULO = 1073741824;

    static int[,] pows = new int[101, 101];
    static int[] dl;
    private static void solve(MyReader instream, TextWriter outstream)
    {
        int[] abc = instream.ReadIntArray();

        List<int> primes = new List<int>();
        primes.Add(2);
        for (int i = 3; i <= 100; i++)
        {
            bool ok = true;
            foreach (int p in primes)
            {
                if (i % p == 0) ok = false;
            }
            if (ok) primes.Add(i);
        }
        dl = primes.ToArray();

        for (int x = 2; x <= 100; x++)
        {
            int xx = x;

            for (int pi = 0; pi < dl.Length && dl[pi]<=x ; pi++)
            {
                int po = dl[pi];

                while (xx % po == 0)
                {
                    pows[x, pi]++;
                    xx /= po;
                }
            }
        }

        int[] total_pows = new int[100];
        long res = 0;

        for (int a = 1; a <= abc[0]; a++)
            for (int b = 1; b <= abc[1]; b++)
                for (int c = 1; c <= abc[2]; c++)
                {
                    for (int i = 0; i < dl.Length; i++)
                        total_pows[i] = 0;

                    for (int i = 0, n = a; i < dl.Length; i++)
                        total_pows[i] += pows[n, i];
                    for (int i = 0, n = b; i < dl.Length; i++)
                        total_pows[i] += pows[n, i];
                    for (int i = 0, n = c; i < dl.Length; i++)
                        total_pows[i] += pows[n, i];

                    long subres = 1;
                    for (int i = 0; i < dl.Length; i++)
                    {
                        subres = subres * (total_pows[i] + 1) % MODULO;
                    }
                    res = (res + subres) % MODULO;
                }

        outstream.WriteLine(res);
    }

}


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

namespace aDefintieGame
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            bool done = true;
            while (done)
            {
                if (n - 1 != 0 && n % (n - 1) != 0)
                {
                    n = n - (n - 1);
                }
                else if (n - 2 != 0 && n % (n - 2) != 0)
                {
                    n = n - (n - 2);
                }
                else
                {
                    done = false;
                }
            }
            Console.WriteLine(n);
        }
    }
}


/*
csc -debug A.cs && mono --debug A.exe <<< "8"
*/

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

public class HelloWorld {
    static public void Main () {
        SolveCodeForces();
    }

    public static void SolveCodeForces() {
        var sc = new Scanner();
        var n = sc.NextLong();
        System.Console.WriteLine(n == 2 ? 2 : 1);
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }

    public static T ElementWithMax<T>(this IEnumerable<T> seq, Func<T, long> func) {
        var bi = default(T);
        var bv = long.MinValue;
        foreach (var item in seq) {
            var v = func(item);
            if (v > bv) {
                bi = item;
                bv = v;
            }
        }
        return bi;
    }

    public static IEnumerable<int> IndicesWhere<T>(this IEnumerable<T> seq, Func<T, bool> cond) {
        var i = 0;
        foreach (var item in seq) {
            if (cond(item)) yield return i;
            i++;
        }
    }
}

public 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 ulong NextUlong() {
        return ulong.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;
    }

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


using System;

public class Program
{
	public static void Main()
	{
		int[] tmp = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
		string s = Console.ReadLine();

		int n = tmp[0];
		int d = tmp[1];
		string str = "";

		for(int j=0; j < d; j++)
		{
		   	str += "0";
		}

		if(s.IndexOf(str) > -1)
		{
			Console.WriteLine(-1);
			return;
		}

		int i = 0;
		int count = 0;
		while(i < n-1)
		{
			if(s[i] == '1')
			{
			   i += d;
				count++;
			}
			else
			   i--;
		}
		Console.WriteLine(count);

	}
}


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

namespace CodeForces
{
    class Program
    {

        static void Main(string[] args)
        {
            string firstLine = Console.ReadLine();
            string[] numbers = firstLine.Split(' ');

            int wordLength =int.Parse(numbers[0]);
            int MaxJump = int.Parse(numbers[1]);
            int next = 0;
            string way = Console.ReadLine();
            int steps=0;
            bool outofrange=false;

            for (int pointer = 0; pointer < wordLength-1; )
            {
                //Bring Maximum 1 after My Jump
                next = pointer + MaxJump;

                if (next < wordLength && way[next] == '1')
                {
                    steps++;
                    pointer = next;
                }
                else
                {
                    int j;
                    if (next > wordLength)
                    {
                        steps++;
                        break;
                    }
                    for ( j = next-1; j > pointer; j--)
                    {
                        if (j<wordLength && way[j] == '1'  )
                        {
                            next = j;
                            pointer = next;
                            steps++;
                        }
                    }
                    if (j == pointer)
                    {
                        outofrange = true;
                        break;
                    }
                }
            }
            if (outofrange)
                Console.WriteLine("-1");
            else
            Console.WriteLine(steps);

        }

    }
}


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

namespace codeforces
{
    class Program
    {
        class Flow
        {
            public int to;
            public int capacity;
            public int flow;
            public int cost;
            public int iRevEdge;

            public Flow(int to, int capacity, int flow, int cost, int iRevEdge)
            {
                this.to = to;
                this.capacity = capacity;
                this.flow = flow;
                this.cost = cost;
                this.iRevEdge = iRevEdge;
            }
        }

        class CompareVertex : IComparer<int>
        {
            public int Compare(int x, int y)
            {
                int v = d[x].CompareTo(d[y]);
                return v != 0 ? v : x.CompareTo(y);
            }
        }

        const int N = 80;

        static int[] di = new int[4] { 0, 0, -1, 1 };
        static int[] dj = new int[4] { -1, 1, 0, 0 };

        static int n, m;
        static int[,] a = new int[N, N];

        static int[] d = new int[N * N + 2];
        static int[] phi = new int[N * N + 2];
        static int[] parent = new int[N * N + 2];
        static int[] numEdge = new int[N * N + 2];
        static List<Flow>[] G = new List<Flow>[N * N + 2];
        static SortedSet<int> sVertex = new SortedSet<int>(new CompareVertex());
        static int minCost = 0;

        static void AddEdge(int from, int to, int cap, int cost)
        {
            G[from].Add(new Flow(to, cap, 0, cost, G[to].Count));
            G[to].Add(new Flow(from, 0, 0, -cost, G[from].Count - 1));
        }

        static bool FindPath(int from, int to)
        {
            for (int i = 0; i <= to; ++i)
            {
                d[i] = int.MaxValue;
            }
            int v;
            sVertex.Clear();
            d[from] = 0;
            sVertex.Add(from);
            while (sVertex.Count > 0)
            {
                v = sVertex.Min;
                sVertex.Remove(v);

                for (int i = 0; i < G[v].Count; ++i)
                {
                    var f = G[v][i];
                    if (f.flow < f.capacity && d[f.to] > d[v] + f.cost - phi[v] + phi[f.to])
                    {
                        if (sVertex.Contains(f.to))
                        {
                            sVertex.Remove(f.to);
                        }
                        d[f.to] = d[v] + f.cost - phi[v] + phi[f.to];
                        sVertex.Add(f.to);
                        parent[f.to] = v;
                        numEdge[f.to] = i;
                    }
                }
            }

            if (d[to] == int.MaxValue)
            {
                return false;
            }
            for (int i = 0; i <= to; ++i)
            {
                if (d[i] != int.MaxValue)
                {
                    phi[i] += d[i];
                }
            }
            v = to;
            int flow = int.MaxValue;
            while (v != from)
            {
                int u = parent[v];
                flow = Math.Min(flow, G[u][numEdge[v]].capacity - G[u][numEdge[v]].flow);
                v = u;
            }

            v = to;
            while(v != from)
            {
                int u = parent[v];
                G[u][numEdge[v]].flow += flow;
                G[v][G[u][numEdge[v]].iRevEdge].flow -= flow;
                minCost += flow * G[u][numEdge[v]].cost;
                v = u;
            }
            return true;

        }

        static void Main(string[] args)
        {
            var t = Console.ReadLine().Split(' ');
            n = int.Parse(t[0]);
            m = int.Parse(t[1]);
            for (int i = 0; i < n; ++i)
            {
                t = Console.ReadLine().Split(' ');
                for (int j = 0; j < m; ++j)
                {
                    a[i, j] = int.Parse(t[j]);
                }
            }
            int from = n * m;
            int to = n * m + 1;
            for (int i = 0; i <= to; ++i)
            {
                phi[i] = 0;
                G[i] = new List<Flow>();
            }

            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < m; ++j)
                {
                    if ((i + j) % 2 == 0)
                    {
                        AddEdge(from, i * m + j, 1, 0);
                        for (int k = 0; k < 4; ++k)
                        {
                            int ei = i + di[k];
                            int ej = j + dj[k];
                            if (ei >= 0 && ei < n && ej >= 0 && ej < m)
                            {
                                AddEdge(i * m + j, ei * m + ej, 1, a[i, j] == a[ei, ej] ? 0 : 1);
                            }
                        }
                    }
                    else
                    {
                        AddEdge(i * m + j, to, 1, 0);
                    }

                }
            }

            while (FindPath(from, to)) { }

            Console.WriteLine(minCost);

            Console.Read();
        }

    }
}


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    class Edge<T>
    {
        public int To, Inv;
        public T Capacity, Cost, Flow;
        public Edge(int to, int inv, T capacity, T cost, T flow)
        {
            To = to;
            Inv = inv;
            Capacity = capacity;
            Cost = cost;
            Flow = flow;
        }
    }

    static void AddEdge(List<Edge<int>>[] g, int from, int to, int capacity, int cost)
    {
        g[from].Add(new Edge<int>(to, g[to].Count, capacity, cost, 0));
        g[to].Add(new Edge<int>(from, g[from].Count - 1, 0, -cost, 0));
    }

    int MinCost(List<Edge<int>>[] g, int source, int sink, int limit)
    {
        const int INF = int.MaxValue / 2;

        int n = g.Length;
        int flow = 0, cost = 0;
        while (flow < limit)
        {
            var id = new int[n];
            var dist = Enumerable.Repeat(INF, n).ToArray();
            var q = new int[n];
            var path = new int[n];
            var epath = new int[n];
            int qh = 0, qt = 0;
            q[qt++] = source;
            dist[source] = 0;
            while (qh != qt)
            {
                int v = q[qh++];
                if (qh == n)
                    qh = 0;
                id[v] = 2;
                for (int i = 0; i < g[v].Count; i++)
                {
                    var r = g[v][i];
                    if (r.Flow < r.Capacity && dist[v] + r.Cost < dist[r.To])
                    {
                        dist[r.To] = dist[v] + r.Cost;
                        if (id[r.To] == 0)
                        {
                            q[qt++] = r.To;
                            if (qt == n)
                                qt = 0;
                        }
                        else if (id[r.To] == 2)
                        {
                            if (--qh == -1)
                                qh = n - 1;
                            q[qh] = r.To;
                        }
                        id[r.To] = 1;
                        path[r.To] = v;
                        epath[r.To] = i;
                    }
                }
            }
            if (dist[sink] == INF)
                break;
            int addflow = limit - flow;
            for (int v = sink; v != source; v = path[v])
            {
                int pv = path[v];
                int pr = epath[v];
                addflow = Math.Min(addflow, g[pv][pr].Capacity - g[pv][pr].Flow);
            }
            for (int v = sink; v != source; v = path[v])
            {
                int pv = path[v];
                int pr = epath[v], r = g[pv][pr].Inv;
                g[pv][pr].Flow += addflow;
                g[v][r].Flow -= addflow;
                cost += g[pv][pr].Cost * addflow;
            }
            flow += addflow;
        }
        return cost;
    }

    private int[] dr = {1, 0, -1, 0};
    private int[] dc = {0, 1, 0, -1};

    public void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        var a = ReadIntMatrix(n);

        var g = Enumerable.Repeat(0, n * m + 2).Select(x => new List<Edge<int>>()).ToArray();
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
            {
                int x = i * m + j;
                if ((i + j) % 2 == 0)
                {
                    AddEdge(g, n * m, x, 1, 0);
                    for (int k = 0; k < 4; k++)
                    {
                        int ii = i + dr[k];
                        int jj = j + dc[k];
                        if (ii < 0 || ii == n || jj < 0 || jj == m)
                            continue;
                        AddEdge(g, x, ii * m + jj, 1, a[i][j] == a[ii][jj] ? 0 : 1);
                    }
                }
                else
                {
                    AddEdge(g, x, n * m + 1, 1, 0);
                }
            }

        Write(MinCost(g, n * m, n * m + 1, n * m / 2));
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("game.in");
        //writer = new StreamWriter("game.out");
#endif
        try
        {
            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 256);
            thread.Start();
            thread.Join();
            //new Solver().Solve();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }

    #endregion
}