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

namespace ConsoleApplication1 {
    struct Pair {
        public int X, Y;
        public Pair(int x, int y) {
            X = x;
            Y = y;
        }
        public override string ToString() {
            return string.Format("{0} {1}", X, Y);
        }
    }

    class Graph : List<List<int>> {
        public Graph(int num) : base(num) {
            for (int i = 0; i < num; i++) {
                this.Add(new List<int>());
            }
        }
    }

    class Program {
        static int n, m, k, t, ans;
        static TextReader input;
        static int[] f;
        static bool[] u1, u2;
        static Graph g, rg;
        static void Main(string[] args) {
#if TESTS
            Stopwatch sw = new Stopwatch();
            sw.Start();
            input = new StreamReader("input.txt");
#else
            input = Console.In;
#endif
            Solve();
#if TESTS
            Console.WriteLine();
            Console.WriteLine("Milliseconds: {0}", sw.ElapsedMilliseconds);
            Console.ReadLine();
#endif
        }

        #region read helpers
        public static int[] ReadIntArray() {
            return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }

        public static List<int> ReadIntList() {
            return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        }

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

        #endregion

        static void Solve() {
            int[] a = ReadIntArray();
            n = a[0];
            m = a[1];
            g = new Graph(n);
            rg = new Graph(n);
            u1 = new bool[n];
            u2 = new bool[n];
            f = ReadIntArray();
            for (int i = 0; i < m; i++) {
                int[] b = ReadIntArray();
                g[--b[0]].Add(--b[1]);
                rg[b[1]].Add(b[0]);
            }
            for (int i = 0; i < n; i++) {
                if (f[i] == 1 && !u1[i]) {
                    Bfs1(i);
                }
            }
            for (int i = 0; i < n; i++) {
                if (f[i] == 2 && !u2[i]) {
                    Bfs2(i);
                }
            }
            for (int i = 0; i < n; i++) {
                if (u1[i] && u2[i])
                    Console.WriteLine(1);
                else
                    Console.WriteLine(0);
            }
        }

        static void Bfs1(int v) {
            u1[v] = true;
            Queue<int> q = new Queue<int>();
            q.Enqueue(v);
            while (q.Count > 0) {
                int u = q.Dequeue();
                foreach (int i in g[u]) {
                    if (!u1[i]) {
                        u1[i] = true;
                        q.Enqueue(i);
                    }
                }
            }
        }

        static void Bfs2(int v) {
            u2[v] = true;
            Queue<int> q = new Queue<int>();
            q.Enqueue(v);
            while (q.Count > 0) {
                int u = q.Dequeue();
                foreach (int i in rg[u]) {
                    if (!u2[i]) {
                        u2[i] = true;
                        if (f[i] != 1)
                            q.Enqueue(i);
                    }
                }
            }
        }

        static void Dfs1(int v) {
            u1[v] = true;
            foreach (int i in g[v]) {
                if (!u1[i]) Dfs1(i);
            }
        }

        static void Dfs2(int v) {
            u2[v] = true;
            if (f[v] == 1) return;
            foreach (int i in rg[v]) {
                if (!u2[i]) Dfs2(i);
            }
        }

        static int[] Count_Sort(int[] a, int k) {
            int n = a.Length;
            int[] b = new int[n];
            int[] c = new int[k];
            for (int i = 0; i < n; ++i)
                ++c[a[i]];
            for (int i = 1; i < k; ++i)
                c[i] += c[i - 1];
            for (int i = n - 1; i >= 0; --i) {
                b[c[a[i]] - 1] = a[i];
                --c[a[i]];
            }
            return b;
        }

        static void Radix_Sort(int[] a, int k) {
            int n = a.Length;
            int repeats = 32 / k;
            int size = 1 << k;
            int mask = size - 1;
            for (int i = 0; i < repeats; ++i) {
                int[] c = new int[size];
                int[] b = new int[n];
                for (int j = 0; j < n; ++j) {
                    int r = (a[j] & (mask << (i * k))) >> (i * k);
                    ++c[r];
                }
                for (int j = 1; j < size; ++j)
                    c[j] += c[j - 1];
                for (int j = n - 1; j >= 0; --j) {
                    int r = (a[j] & (mask << (i * k))) >> (i * k);
                    b[c[r] - 1] = a[j];
                    --c[r];
                }
                Array.Copy(b, a, n);
            }
        }
    }

    public static class Extensions {
        public static void Print<T>(this IEnumerable<T> e) {
            foreach (T item in e) {
                Console.Write("{0} ", item);
            }
        }
    }
}


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

namespace mono
{
    public class Program
    {
        public static char res(int a, int b)
        {
            return a > b ? '+' : (a < b ? '-' : '0');
        }

        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] arr = s.Split(new char[]{ ' ' });
            char c;
            Console.WriteLine((c = res(int.Parse(arr[0]) + int.Parse(arr[2]), int.Parse(arr[1]))) == res(int.Parse(arr[0]), int.Parse(arr[1]) + int.Parse(arr[2])) ? c : '?');
        }
    }
}


using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int x=Convert.ToInt32(s[0]), y=Convert.ToInt32(s[1]), z=Convert.ToInt32(s[2]);
            if (x-y+z<0 && x-y-z<0) Console.WriteLine("-");
            if (x-y+z>0 && x-y-z>0) Console.WriteLine("+");
            if (x-y+z==0 && x-y-z==0) Console.WriteLine("0");
            if ((x-y+z>0 && x-y-z<0) || (x-y+z<0 && x-y-z>0) ||(x-y+z<0 && x-y-z==0) || (x-y+z>0 && x-y-z==0) || (x-y+z==0 && x-y-z>0) || (x-y+z==0 && x-y-z<0)) Console.WriteLine("?");

        }
    }
}


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

public static class Intparser
{
    public static int ToInt32(this string text)
    {
        return Convert.ToInt32(text);
    }
    public static long ToInt64(this string text)
    {
        return Convert.ToInt64(text);
    }
}

class Program
{
    private static void Main(string[] args)
    {
        var ins = Console.ReadLine().Split(' ').Select(x => x.ToInt64()).ToArray();

        if (ins[0] >= ins[1])
        {

            var max = ins[1] / 2;

            if (ins[1] % 2 == 0)
                max--;

            Console.WriteLine(max);

        }
        else
        {
            var sub = ins[1] - ins[0];

            if (sub > ins[0])
            {
                Console.WriteLine(0);
            }
            else
            {
                sub = ins[0] - sub;
                sub = (sub / 2) + sub % 2;

                Console.WriteLine(sub);
            }
        }
    }
}


using System;
using System.Collections.Generic;

namespace Code_Force
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            long k = Int64.Parse(S.Remove(0, S.IndexOf(' ')));
            long n = Int64.Parse(S.Remove(S.IndexOf(' ')));
            if (n == .5 * (k + 1)&k!=1) Console.WriteLine(1);
            else if (n < .5 * (k + 1)) Console.WriteLine(0);
            else if (n >= k) Console.WriteLine((k - 1) / 2);
            else
            {
                long dif = k - n-1;
                Console.WriteLine(((k - 1) / 2)-dif);
            }
        }

    }
}


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

namespace TaskC
{
    class Program
    {
        static void Main(string[] args)
        {
            new Solver().Solve().OutputResult();
        }

        private class ExtendedReader : StreamReader
        {
            private static readonly char Separator = ' ';

            public ExtendedReader(Stream stream) : base(stream) { }
            public ExtendedReader(Stream stream, bool detectEncodingFromByteOrderMarks) : base(stream, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(Stream stream, Encoding encoding) : base(stream, encoding) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(stream, encoding, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize, bool leaveOpen) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen) { }
            public ExtendedReader(string path) : base(path) { }
            public ExtendedReader(string path, bool detectEncodingFromByteOrderMarks) : base(path, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(string path, Encoding encoding) : base(path, encoding) { }
            public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(path, encoding, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(path, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }

            public char ReadChar()
            {
                return (char)this.Read();
            }

            public double ReadDoubleFromArray()
            {
                StringBuilder sb = new StringBuilder();
                char ch = this.ReadChar();
                while (ch != Separator && ch != '\n')
                {
                    sb.Append(ch);
                    ch = this.ReadChar();
                }
                return Convert.ToDouble(sb.ToString());
            }

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

            public Int64 ReadInt64()
            {
                return Int64.Parse(this.ReadLine());
            }

            public int[] ReadIntArray()
            {
                return this.ReadLine().Split(' ').Select(int.Parse).ToArray();
            }

            public char[] ReadCharArray()
            {
                return this.ReadLine().ToCharArray();
            }

            public string ReadString()
            {
                return this.ReadLine();
            }

            public Int64[] ReadInt64Array()
            {
                return this.ReadLine().Split(Separator).Select(Int64.Parse).ToArray();
            }

            public Double[] ReadDoubleArray()
            {
                return this.ReadLine().Split(Separator).Select(Double.Parse).ToArray();
            }
        }

        private abstract class SolverBase
        {
            protected readonly ExtendedReader _reader;
            protected readonly TextWriter _writer;

            protected SolverBase()
            {
#if DEBUG
                _reader = new ExtendedReader(@"input.txt");
                //_writer = new StreamWriter(@"output.txt");
                _writer = new StreamWriter(Console.OpenStandardOutput());
#else
                _reader = new ExtendedReader(Console.OpenStandardInput());
                _writer = new StreamWriter(Console.OpenStandardOutput());
#endif
            }

            public abstract Solver Solve();

            public abstract void OutputResult();
        }

        private class Solver : SolverBase
        {
            private long result = -1L;

            public override Solver Solve()
            {
                // link to task: http://codeforces.com/contest/689/problem/C

                var m = _reader.ReadInt64();
                long lower = 1;
                long upper = (long)1e16;
                while (upper - lower > 1)
                {
                    long middle = (lower + upper) / 2;

                    var M = CalcM(middle);
                    if (M >= m)
                        upper = middle;
                    else
                        lower = middle;
                }

                if (CalcM(upper) == m)
                    result = upper;

                return this;
            }

            static long CalcM(long n)
            {
                long M = 0;
                for (long k = 2; k * k * k <= n; k++)
                {
                    M += n / (k * k * k);
                }
                return M;
            }

            public override void OutputResult()
            {
                string answer = result.ToString();

                _writer.WriteLine(answer);
                _writer.Dispose();
            }
        }
    }
}


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

class Program
{
    static long calc(long med)
    {
        var calc = 0L;
        var st = 2;
        while (med / st / st / st > 0)
        {
            calc += med / st / st / st;
            st++;
        }
        return calc;
    }

    static void solve(StreamReader reader, StreamWriter writer)
    {
        long m = reader.ReadLong();
        var min = 1L;
        var max = (long)1e18;
        while (max - min > 1)
        {
            var med = (min + max)/2;
            var cl = calc(med);
            if (cl >= m)
                max = med;
            else
                min = med;
        }
        if (calc(min) == m)
            writer.WriteLine(min);
        else if (calc(max) == m)
            writer.WriteLine(max);
        else
            writer.WriteLine(-1);

        //int n = reader.ReadInt();
        //var a = new int[n+1];
        //var r = new int[n+1];
        //for (int i = 1; i <= n; ++i)
        //{
        //    a[i] = reader.ReadInt();
        //    r[i] = i-1;
        //}

        //for (int j = 1; j <= n; ++j)
        //{
        //    if (j < n)
        //        r[j+1] = Math.Min(r[j+1], r[j] + 1);
        //    r[a[j]] = Math.Min(r[a[j]], r[j] + 1);
        //}
        //for (int j = 1; j <= n; ++j)
        //{
        //    writer.Write(r[j] + " ");
        //}
    }

    #region launch
    static void Main(string[] args)
    {
        using (var writer = new FormattedStreamWriter(Console.OpenStandardOutput()))
        {
            using (var reader = new StreamReader(
#if CODECHIEF_LOCAL
    "input.txt"
#else
Console.OpenStandardInput()
#endif
))
            {
                solve(reader, writer);
            }
        }
    }
    #endregion
}

#region helpers
class FormattedStreamWriter : StreamWriter
{
    public FormattedStreamWriter(Stream stream)
        : base(stream)
    {
    }

    public override IFormatProvider FormatProvider
    {
        get
        {
            return CultureInfo.InvariantCulture;
        }
    }
}

static class IOExtensions
{
    public static string ReadString(this StreamReader reader)
    {
        return reader.ReadToken();
    }

    public static int ReadInt(this StreamReader reader)
    {
        return int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
    }

    public static long ReadLong(this StreamReader reader)
    {
        return long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
    }

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

    static Queue<string> buffer = new Queue<string>(100);

    static string ReadToken(this StreamReader reader)
    {
        while (buffer.Count == 0)
        {
            reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach((t) =>
            {
                buffer.Enqueue(t);
            });
        }
        return buffer.Dequeue();
    }
}
#endregion


// done
/***************************************************************************
* Title : Almost Prime
* URL   : http://codeforces.com/problemset/problem/26/A
* Contst: Offline
* Date  : 2018-04-27
* Author: Atiq Rahman
* Comp  : O(N)
* Status: Accepted
* Notes : This is not really a good problem for practicing implementation of
*   doubly linked list. Building LinkedList is not trivial since nodes are out
*   of order.. we can say this place for practicing alternative doubly linked
*   list representation.
*
*   Applications of this problem:
*   Test Prime Number Generatation algorithm up to a small range (<=3000)
*
*   With this problem following Prime Generation Algos tested,
*   - Dynamic Programming Approach for generating primes
*   - Sieve of Eratosthenes
*
*   related: 'uva-online-judge/old/10699_Count the factors.cpp'
* meta  : tag-linked-list, tag-easy
***************************************************************************/
using System;
using System.Collections.Generic;

public class PrimeUtil {
  // The access level for class members and struct members, including nested
  // classes and structs, is private by default.
  // ref: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/
  // classes-and-structs/access-modifiers
  List<int> primes;
  System.Collections.BitArray isPrime;
  int n;

  // Divide each candidate number (starting from 6) by prime numbers to find
  // divisors. Keep dividing the number with the divisor/factor. Do it twice
  // and if the number comes down to one after those divisions we got an
  // almost prime
  public int FindAlmostPrimes()
  {
    int count = 0;

    for (int num = 6; num <= n; num++) {
      int firstPrimeDivisorIndex = GetPrimeFactor(num);
      if (firstPrimeDivisorIndex == -1)
        continue;
      // divide the number as long as it is divisible by factor
      int dNum = DivideDown(num, primes[firstPrimeDivisorIndex]);
      int secondPrimeDivisorIndex = GetPrimeFactor(dNum, firstPrimeDivisorIndex
        + 1);
      if (secondPrimeDivisorIndex == -1)
        continue;
      if (DivideDown(dNum, primes[secondPrimeDivisorIndex]) == 1)
        count++;
    }
    return count;
  }

  // start from the index after the previous prime factor's index
  private int GetPrimeFactor(int num, int startIndex=0) {
    if (num == 1)
      return -1;
    // find prime divisor/factor
    for (int i= startIndex; primes[i] <= num && i<primes.Count; i++)
      if (num % primes[i] == 0)
        return i;
    return -1;
  }

  private int DivideDown(int num, int factor) {
    while (num % factor == 0)
      num /= factor;
    return num;
  }

  // Dynamic Programming for generating primes
  // O(N*C)
  /* public void GeneratePrimes()
  {
    primes = new List<int>(new int[] { 2 });
    for (int j = 3; j <= n; j += 2) {
      int pi = 1;   // index inside the prime number collection
      for (; pi < primes.Count; pi++)
        if (j % primes[pi] == 0)
          break;
      if (pi == primes.Count)
        primes.Add(j);
    }
  }*/

  /*
   consider example,
   2, 3, 4,
  */
  // Sieve
  public void GeneratePrimes()
  {
    isPrime = new System.Collections.BitArray(n + 1, true);
    for (int i = 3; i * i <= n; i+=2)
      if (isPrime.Get(i))
        for (int j = i * i; j <= n; j += i)
          isPrime.Set(j, false);

    primes = new List<int>(new int[] { 2 });
    for (int i = 3; i <= n; i+=2)
      if (isPrime.Get(i))
        primes.Add(i);
  }

  public void Input()
  {
    n = int.Parse(Console.ReadLine());
  }
}

public class CF_Solution {
  public static void Main() {
    PrimeUtil primeDemo = new PrimeUtil();
    primeDemo.Input();
    primeDemo.GeneratePrimes();
    Console.WriteLine(primeDemo.FindAlmostPrimes());
  }
}


// done
/***************************************************************************
* Title : Almost Prime
* URL   : http://codeforces.com/problemset/problem/26/A
* Contst: Offline
* Date  : 2018-04-27
* Author: Atiq Rahman
* Comp  : O(N)
* Status: Accepted
* Notes : This is not really a good problem for practicing implementation of
*   doubly linked list. Building LinkedList is not trivial since nodes are out
*   of order.. we can say this place for practicing alternative doubly linked
*   list representation.
*
*   Applications of this problem:
*   Test Prime Number Generatation algorithms
* meta  : tag-linked-list, tag-easy
***************************************************************************/
using System;
using System.Collections.Generic;

public class PrimeUtil {
  // The access level for class members and struct members, including nested
  // classes and structs, is private by default.
  // ref: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/
  // classes-and-structs/access-modifiers
  List<int> primes;
  int n;

  // Divide each candidate number (starting from 6) by prime numbers to find
  // divisors. Keep dividing the number with the divisor/factor. Do it twice
  // and if the number comes down to one after those divisions we got an
  // almost prime
  public int FindAlmostPrimes()
  {
    int count = 0;

    for (int num = 6; num <= n; num++) {
      int firstPrimeDivisorIndex = GetPrimeFactor(num);
      if (firstPrimeDivisorIndex == -1)
        continue;
      // divide the number as long as it is divisible by factor
      int dNum = DivideDown(num, primes[firstPrimeDivisorIndex]);
      int secondPrimeDivisorIndex = GetPrimeFactor(dNum, firstPrimeDivisorIndex
        + 1);
      if (secondPrimeDivisorIndex == -1)
        continue;
      if (DivideDown(dNum, primes[secondPrimeDivisorIndex]) == 1)
        count++;
    }
    return count;
  }

  // start from the index after the previous prime factor's index
  private int GetPrimeFactor(int num, int startIndex=0) {
    if (num == 1)
      return -1;
    // find prime divisotr/factor
    for (int i= startIndex; primes[i] <= num && i<primes.Count; i++)
      if (num % primes[i] == 0)
        return i;
    return -1;
  }

  private int DivideDown(int num, int factor) {
    while (num % factor == 0)
      num /= factor;
    return num;
  }

  // Dynamic Programming for generating primes
  // O(N*C)
  public void GeneratePrimes() {
    primes = new List<int>(new int[] { 2 });
    for (int j = 3; j <= n; j += 2) {
      int pi = 1;   // index inside the prime number collection
      for (; pi < primes.Count; pi++)
        if (j % primes[pi] == 0)
          break;
      if (pi == primes.Count)
        primes.Add(j);
    }
  }

  public void Input()
  {
    n = int.Parse(Console.ReadLine());
  }
}

public class CF_Solution {
  public static void Main() {
    PrimeUtil primeDemo = new PrimeUtil();
    primeDemo.Input();
    primeDemo.GeneratePrimes();
    Console.WriteLine(primeDemo.FindAlmostPrimes());
  }
}


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

class Solver
{
    public void Solve(Scanner sc)
    {
        int N, M;
        sc.Make(out N, out M);
        int[] res = new int[N],ex=new int[N];
        int[] ct = new int[M],ts=new int[M];

        var pq = new PriorityQueue<Pi>((a,b)=>a.v1-b.v1);
        for(var i = 0; i < M; i++)
        {
            int s, t, c;
            sc.Make(out s, out t, out c);
            s--;t--;
            res[t] = M+1;
            ts[i] = t;
            ex[t] = i;
            pq.Push(new Pi(s,i));
            ct[i] = c;
        }
        var f = new PriorityQueue<Pair<int,int,int>>((a, b) => a.v1 - b.v1);
        var use = new bool[M];
        for(var i = 0; i < N; i++)
        {
            while (pq.Any() && pq.Top.v1 == i)
                f.Push(new Pair<int,int,int>(ts[pq.Top.v2], ct[pq.Top.v2],pq.Pop().v2));
            if (res[i] == M+1)
            {
                if (!use[ex[i]]) Fail(-1);
                continue;
            }
            if (!f.Any()) continue;
            var p = f.Pop();
            res[i] = p.v3+1;
            p.v2--;
            if (p.v2 != 0) f.Push(p);
            else use[p.v3] = true;
        }

        Console.WriteLine(string.Join(" ", res));

    }
}

public class PriorityQueue<T>
{
    private List<T> data = new List<T>();
    private Comparison<T> cmp;
    public int Count { get { return data.Count; } }
    public T Top { get { return data[0]; } }
    public PriorityQueue() { cmp = cmp ?? Comparer<T>.Default.Compare; }

    public PriorityQueue(Comparison<T> comparison) { cmp = comparison; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private int Parent(int i)
        => (i - 1) >> 1;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private int Left(int i)
        => (i << 1) + 1;
    public T Push(T val)
    {
        int i = data.Count;
        data.Add(val);
        while (i > 0)
        {
            int p = Parent(i);
            if (cmp(data[p], val) <= 0)
                break;
            data[i] = data[p];
            i = p;
        }
        data[i] = val;
        return val;
    }
    public T Pop()
    {
        var ret = data[0];
        var p = 0;
        var x = data[data.Count - 1];
        while (Left(p) < data.Count - 1)
        {
            var l = Left(p);
            if (l < data.Count - 2 && cmp(data[l + 1], data[l]) < 0) l++;
            if (cmp(data[l], x) >= 0)
                break;
            data[p] = data[l];
            p = l;
        }
        data[p] = x;
        data.RemoveAt(data.Count - 1);
        return ret;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public bool Any() => data.Count > 0;
}
#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b)
    { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f();
        return rt;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<int, T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f(i);
        return rt;
    }
    public static T[] Copy<T>(this T[] A)
        => Create(A.Length, i => A[i]);
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}

public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    public Pair<T1, T2> PairMake<T1, T2>() => new Pair<T1, T2>(Next<T1>(), Next<T2>());
    public Pair<T1, T2, T3> PairMake<T1, T2, T3>() => new Pair<T1, T2, T3>(Next<T1>(), Next<T2>(), Next<T3>());
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
}

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

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

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

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


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

namespace Petya_Exam
{
    class Program
    {
        struct Exam
        {
            public int ExamIndex;
            public int Publish;
            public int ExamDay;
            public int PrepDays;
        }

        static void Main(string[] args)
        {
            List<Exam> list2 = new List<Exam>();
            int N_Days;
            int Total_exams;

                string[] s = (Console.ReadLine()).Split(' ');
                N_Days = int.Parse(s[0]);
                Total_exams = int.Parse(s[1]);

                for (int i = 0; i < Total_exams; ++i)
                {
                    Exam exm;
                    s = (Console.ReadLine()).Split(' ');
                    exm.ExamIndex = i + 1;
                    exm.Publish = int.Parse(s[0]);
                    exm.ExamDay = int.Parse(s[1]);
                    exm.PrepDays = int.Parse(s[2]);
                    list2.Add(exm);
                }

           list2.Sort((x, y) => x.ExamDay.CompareTo(y.ExamDay));
            List<int> seq = new List<int>();
            for (int i = 0; i <= N_Days; ++i)
            {
                seq.Add(0);
            }
            int print = 0;
            foreach (Exam l in list2)
            {
                if (l.Publish - 1 + l.PrepDays < l.ExamDay)
                {
                    if (Ispossible(l.ExamIndex, l, seq))
                    {
                        seq[l.ExamDay] = Total_exams + 1;

                        continue;
                    }
                    else
                    {
                        print = -1;
                        break;
                    }
                }
                else
                {
                    print = -1;
                    break;
                }
            }
            if (print == 0)
            {
                if (seq.Sum() != 0)
                {
                    for (int j = 1; j < seq.Count; ++j)
                    {
                        if (j + 1 == seq.Count)
                        {
                            Console.Write(seq[j]);
                            continue;
                        }
                        Console.Write(seq[j] + " ");
                    }
                }
                else
                {
                    Console.WriteLine("-1");
                }
            }
            else
            {
                Console.WriteLine("-1");
            }

            //Console.ReadKey();
        }

        private static bool Ispossible(int exam_number, Exam l, List<int> seq)
        {
            int days = l.PrepDays;

            int i = l.Publish;
            while (i < l.ExamDay && days > 0)
            {
                if (seq[i] == 0)
                {
                    seq[i] = exam_number;
                    days--;
                }
                i++;
            }
            return days == 0 ? true : false;
        }

    }
}


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

namespace CodeForces.PRACTICE
{
    // Kyoya and Photobooks (brute force, math)
    class _554A
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            // egyik megoldas:
            //Console.WriteLine((s.Length + 1) * 25 + 1);

            HashSet<string> set = new HashSet<string>();

            int n = s.Length;
            for (int i = 0; i <= n; i++)
                for (char j = 'a'; j <= 'z'; j++)
                {
                    string t = s.Substring(0, i) + j + s.Substring(i);
                    set.Add(t);
                }
            Console.WriteLine(set.Count);
        }
    }
}


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

class PairVariable : IComparable<PairVariable>
{
    public int a, b;
    public PairVariable()
    {
        a = b = 0;
    }
    public PairVariable(string s)
    {
        string[] q = s.Split();
        a = int.Parse(q[0]);
        b = int.Parse(q[1]);
    }
    public PairVariable(int a, int b)
    {
        this.a = a;
        this.b = b;
    }
    public int CompareTo(PairVariable pv)
    {
        if (this.a > pv.a)
        {
            return 1;
        }
        else if (this.a < pv.a)
        {
            return -1;
        }
        else
        {
            if (this.b >= pv.b)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }

}
namespace ConsoleApplication2
{

    class Program
    {

        static int[,] matrix;
        static int[] mark;

        static void DFS(int v)
        {

            mark[v] = 1;
            for (int i = 0; i < matrix.GetLength(0); i++)
            {

                if (matrix[v, i] == 1)
                {

                    if (mark[v] == 0)
                    {
                        DFS(i);
                    }
                }
            }

        }
        static bool IsPrime(int n)
        {
            for (int i = 2; i <= Math.Sqrt(n); i++)
            {
                if (n % i == 0)
                {
                    return false;
                }
            }
            return true;
        }
        static void IsYesNo(bool b)
        {
            if (b)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
        static void Main(string[] args)
        {
            //string[] ss = Console.ReadLine().Split();
            string s = Console.ReadLine();
            Console.WriteLine(1+((s.Length+1)*25));

        }
    }
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = new string[3];
            for (int i = 0; i < 3;i++)
            {
                s[i] = Console.ReadLine();
            }
            SolveProblem(s);
            Console.ReadLine();

        }

        static void SolveProblem(string [] s)
        {
            Dictionary<char, int> coins = new Dictionary<char, int>();
            coins.Add('A',0);
            coins.Add('B', 0);
            coins.Add('C', 0);

            for (int i = 0; i < s.Length;i++)
            {
                switch (s [i] [1])
                {
                    case '>':
                        coins[s[i][0]] += 1;
                        break;
                    case '<':
                        coins[s[i][2]] += 1;
                        break;

                }
            }

            if (coins ['A'] == coins ['B'] && coins['B'] == coins['C'])
            {
                Console.WriteLine("Impossible");

            } else
            {
                var items = from pair in coins
                            orderby pair.Value ascending
                            select pair;
                foreach (KeyValuePair <char, int> pair in items)
                {
                    Console.Write(pair.Key);
                }
            }
        }

    }

}


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

class Program
{

    void solve()
    {

        string[] s = new string[3];
        for (int i = 0; i < 3; i++)
            s[i] = nextString();
        string all = "ABC";
        foreach (char c1 in all)
            foreach (char c2 in all)
                if (c1 != c2)
                    foreach (char c3 in all)
                        if (c3 != c1 && c3 != c2)
                        {
                            bool ok = true;
                            string cur = "" + c1 + c2 + c3;
                            for (int i = 0; i < 3; i++)
                            {
                                int i1 = cur.IndexOf(s[i][0]);
                                int i2 = cur.IndexOf(s[i][2]);
                                if (s[i][1] == '<')
                                {
                                    if (i1 > i2)
                                        ok = false;
                                }
                                if (s[i][1] == '>')
                                {
                                    if (i1 < i2)
                                        ok = false;
                                }
                            }
                            if (ok)
                            {
                                println(cur);
                                return;
                            }

                        }
        println("Impossible");
    }

    ////////////
    private void println(int[] ar)
    {
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i]);
            else
                print(ar[i] + " ");
        }
    }
    private void println(int[] ar, bool add)
    {
        int A = 0;
        if (add)
            A++;
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i] + A);
            else
                print((ar[i] + A) + " ");
        }
    }

    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        string s = Doublenum.ToString(CultureInfo.InvariantCulture);
        Console.WriteLine(s);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();

    }
    int nextInt()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return int.Parse(inputLine[inputInd++]);
    }
    long nextLong()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return long.Parse(inputLine[inputInd++]);
    }
    double nextDouble()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return double.Parse(inputLine[inputInd++]);
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        new Program().solve();
    }
}


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

namespace CodeForces
{
    static class Program
    {
        static void Main()
        {
            const string filePath = @"Data\R468A.txt";
            if (System.IO.File.Exists(filePath))
            {
                Console.SetIn(new System.IO.StreamReader(filePath));
            }

            IProblem counter = new R468A();

            foreach (var result in counter.GetResults())
            {
                Console.WriteLine(result);
            }
        }
    }

    internal class R468A : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            var a = this.ReadInt32();
            var b = this.ReadInt32();
            var delta = Math.Abs(b - a);
            var s1 = delta / 2;
            var s2 = delta / 2;
            if (delta % 2 == 1)
            {
                s2++;
            }

            yield return ((s1+1)*s1/2+ (s2 + 1) * s2 / 2).ToString();
        }
    }

    internal class R468B : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }

    internal class R468C : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }

    internal class R468D : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }

    abstract class MultipleTestsBase : ProblemBase
    {
        public sealed override IEnumerable<string> GetResults()
        {
            var t = Convert.ToInt32(Console.ReadLine());
            for (int testCaseNumber = 0; testCaseNumber < t; testCaseNumber++)
            {
                foreach (var result in GetTestResult(testCaseNumber + 1))
                {
                    yield return result;
                }

            }

        }

        protected abstract IEnumerable<string> GetTestResult(int caseNumber);
    }

    public interface IProblem
    {
        IEnumerable<string> GetResults();
    }

    public abstract class ProblemBase : IProblem
    {
        /// <summary>
        /// Pring array of T
        /// </summary>
        /// <typeparam name="T">Generic paramter.</typeparam>
        /// <param name="items">The items.</param>
        /// <param name="prefixMessage">The message shown first.</param>
        public void PrintArray<T>(IEnumerable<T> items, string prefixMessage)
        {
            Console.WriteLine("{0}: {1}", prefixMessage, string.Join(",", items));
        }

        public void WriteDiagnostics(string message, params object[] objects)
        {
            Console.WriteLine(message, objects);
        }

        public virtual IEnumerable<string> GetResults()
        {
            yield return "No result";
        }

        protected int[] ReadIntArray()
        {
            return Array.ConvertAll(ReadTokens(), Convert.ToInt32);
        }

        protected string[] ReadTokens()
        {
            var readLine = Console.ReadLine();
            if (readLine == null)
            {
                throw new Exception("Value read from Console is null");
            }
            return readLine.Split(' ');
        }

        protected int ReadInt32()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = Math.Abs(a - b);
            int d = c / 2;
            int e = c - d;
            int f = (1 + d) * d / 2;
            int g = (1 + e) * e / 2;
            int h = f + g;
            Console.WriteLine(h);
            //Console.ReadKey();
        }
    }
}


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

namespace SecTry_1040AF
{
    class Program
    {
        static void Main(string[] args)
        {
            IEnumerable<int> container = Console.ReadLine().Split().Select(int.Parse);
            int n = container.ElementAt(0), whiteCost = container.ElementAt(1), blackCost = container.ElementAt(2), ans = 0;
            List<int> line = Console.ReadLine().Split().Select(int.Parse).ToList();

            for (int i = 0, j = line.Count - 1; i <= j; i++, j--)
            {
                if (i == j && line[i] == 2) ans += Math.Min(whiteCost, blackCost);
                else if (line[i] != 2 && line[j] == 2) ans += line[i] == 0 ? whiteCost : blackCost;
                else if (line[i] == 2 && line[j] != 2) ans += line[j] == 0 ? whiteCost : blackCost;
                else if (line[i] == 2 && line[j] == 2) ans += Math.Min(blackCost, whiteCost)*2;
                else if (line[i] != line[j])
                {
                    ans = -1;
                    break;
                }

            }

            Console.WriteLine(ans);

        }
    }
}


using System;
using System.Linq;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int[] a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int sum = 0;
            for (int i = 0; i < nm[0] / 2; i++)
            {
                if (a[i] != 2 && a[nm[0] - 1 - i] != 2 && a[i] != a[nm[0] - 1 - i])
                {
                    Console.WriteLine(-1);
                    return;
                }
                if (a[i] == a[nm[0] - 1 - i] && a[i] != 2)
                    continue;
                if (a[i] == a[nm[0] - 1 - i] && a[i] == 2)
                    sum += Math.Min(nm[1], nm[2]) * 2;
                else if (a[i] == 2 && a[nm[0] - 1 - i] == 0 || a[i] == 0 && a[nm[0] - 1 - i] == 2)
                    sum += nm[1];
                else sum += nm[2];
            }
            if (nm[0] % 2!=0)
                sum += a[nm[0]/2] == 2 ? Math.Min(nm[1], nm[2]) : 0;
            Console.WriteLine(sum);
        }
    }
}


using System;
using System.Linq;
using CompLib.Util;
using System.Threading;
using CompLib.Mathematics;

public class Program
{
    private int N;

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

        /*
         * 街0 ~ n+1
         *
         * 1/2の確率で 1~nに建てる
         *
         * iにパワーpの建てる
         * 距離p未満の街に届く
         *
         * 0とn+1に届かない
         * 1~nには1つから届く
         *
         *
         */

        // i未満の街に届く
        // iには届いてない
        // 確率
        ModInt[] dp = new ModInt[N + 2];
        dp[1] = 1;

        ModInt odd = 1;
        ModInt even = 0;

        ModInt h = ModInt.Inverse(2);

        for (int i = 2; i <= N + 1; i++)
        {
            odd *= h;
            even *= h;
            if (i % 2 == 0)
            {
                dp[i] = odd;
                even += odd;
            }
            else
            {
                dp[i] = even;
                odd += even;
            }
        }

        Console.WriteLine(dp[N + 1]);
    }

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

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt

    /// <summary>
    /// [0,<see cref="Mod"/>) までの値を取るような数
    /// </summary>
    public struct ModInt
    {
        /// <summary>
        /// 剰余を取る値．
        /// </summary>
        // public const long Mod = (int) 1e9 + 7;
        public const long Mod = 998244353;

        /// <summary>
        /// 実際の数値．
        /// </summary>
        public long num;

        /// <summary>
        /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
        /// </summary>
        /// <param name="n">インスタンスが持つ値</param>
        /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
        public ModInt(long n)
        {
            num = n;
        }

        /// <summary>
        /// このインスタンスの数値を文字列に変換します．
        /// </summary>
        /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
        public override string ToString()
        {
            return num.ToString();
        }

        public static ModInt operator +(ModInt l, ModInt r)
        {
            l.num += r.num;
            if (l.num >= Mod) l.num -= Mod;
            return l;
        }

        public static ModInt operator -(ModInt l, ModInt r)
        {
            l.num -= r.num;
            if (l.num < 0) l.num += Mod;
            return l;
        }

        public static ModInt operator *(ModInt l, ModInt r)
        {
            return new ModInt(l.num * r.num % Mod);
        }

        public static implicit operator ModInt(long n)
        {
            n %= Mod;
            if (n < 0) n += Mod;
            return new ModInt(n);
        }

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

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

        /// <summary>
        /// 与えられた数の逆元を計算します．
        /// </summary>
        /// <param name="v">逆元を取る対象となる数</param>
        /// <returns>逆元となるような値</returns>
        /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
        public static ModInt Inverse(ModInt v)
        {
            return Pow(v, Mod - 2);
        }
    }

    #endregion

    #region Binomial Coefficient

    public class BinomialCoefficient
    {
        public ModInt[] fact, ifact;

        public BinomialCoefficient(int n)
        {
            fact = new ModInt[n + 1];
            ifact = new ModInt[n + 1];
            fact[0] = 1;
            for (int i = 1; i <= n; i++)
                fact[i] = fact[i - 1] * i;
            ifact[n] = ModInt.Inverse(fact[n]);
            for (int i = n - 1; i >= 0; i--)
                ifact[i] = ifact[i + 1] * (i + 1);
            ifact[0] = ifact[1];
        }

        public ModInt this[int n, int r]
        {
            get
            {
                if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
                return fact[n] * ifact[n - r] * ifact[r];
            }
        }

        public ModInt RepeatedCombination(int n, int k)
        {
            if (k == 0) return 1;
            return this[n + k - 1, k];
        }
    }

    #endregion
}

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.CodeForces._1452
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long mask = 998244353;

            long[] dp = new long[n+1];
            dp[0] = 1;
            dp[1] = 1;
            long[] oddSums = new long[n + 1];
            oddSums[1] = 1;
            long[] evenSums = new long[n + 1];
            evenSums[0] = 1;

            for(int i = 2; i <= n; i++)
            {
                if (i % 2 == 1)
                {
                    dp[i] = evenSums[i - 1];
                    dp[i] %= mask;
                    oddSums[i] = oddSums[i - 2] + dp[i];
                    oddSums[i] %= mask;
                }
                else
                {
                    dp[i] = oddSums[i - 1];
                    dp[i] %= mask;
                    evenSums[i] = evenSums[i - 2] + dp[i];
                    evenSums[i] %= mask;
                }
            }

            long div = 1;
            for(int i = 0; i < n; i++)
            {
                div *= 2;
                div %= mask;
            }

            long res = dp[n];
            res *= Inverse(div, mask);
            res %= mask;
            WriteLine(res);
        }

        static long Inverse(long val,long mask)
        {
            long a = mask;
            long b = val % mask;
            long x = 1;
            long x1 = 0;
            long y = 0;
            long y1 = 1;
            while (b > 0)
            {
                long q = a / b;
                long r = a % b;
                long x2 = (mask + x - (q * x1) % mask) % mask;
                long y2 = (mask + y - (q * y1) % mask) % mask;
                a = b;
                b = r;
                x = x1;
                x1 = x2;
                y = y1;
                y1 = y2;
            }
            return y;
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            double q;

            n = int.Parse(Console.ReadLine());
            m = 8 * n + 1;
            q = Math.Sqrt(m);
            if (Math.Truncate(q) == q) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}


using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            var s = 2*Convert.ToInt16(Console.ReadLine());
            var a = (byte) Math.Sqrt(s);
            Console.WriteLine(a*(a+1)==s?"YES":"NO");
        }
    }
}


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

namespace MUH_and_House_of_Cards
{
    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)
        {
            long n = long.Parse(reader.ReadLine());

            if (n < 2)
            {
                writer.WriteLine("0");
            }
            else
            {
                long count = 2;
                long delta = 2;
                int flour = 0;
                while (count <= n)
                {
                    flour++;
                    delta += 3;
                    count += delta;
                }

                if (flour%3 == 2)
                {
                    if (n%3 == 0)
                        flour -= 2;
                    else
                    {
                        flour++;
                    }
                }
                else if (flour%3 == 1)
                {
                    if (n%3 == 2)
                        flour += 2;
                    else
                    {
                        flour--;
                    }
                }

                writer.WriteLine(flour/3);
            }

            writer.Flush();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Enum = System.Linq.Enumerable;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
using BitVector = System.Collections.Specialized.BitVector32;
namespace Solver
{

    public class Solver
    {
        public void Solve()
        {
            var n = sc.Long();
            var count = 0;
            for (long i = 1; i < n; i++)
            {
                var t = 3 * i * (i + 1) / 2;
                var num = n + i;
                if (t > num)
                    break;
                if (num % 3 != 0)
                    continue;
                count++;
            }
            IO.Printer.Out.PrintLine(count);
        }
        internal IO.StreamScanner sc;
    }

    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            System.Diagnostics.Debug.AutoFlush = false;
            var sw = new Watch();
            sw.Start();
            try
            {
#endif
                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                IO.Printer.Out = new IO.Printer(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                System.Diagnostics.Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}
#region IO Helper
namespace Solver.IO
{
    public class Printer
    {
        static Printer()
        {
            Out = new Printer(Console.Out);
        }
        public static Printer Out { get; set; }
        private readonly System.IO.TextWriter writer;
        private readonly System.Globalization.CultureInfo info;
        public string Separator { get; set; }
        public string NewLine { get { return writer.NewLine; } set { writer.NewLine = value ?? "\n"; } }
        public Printer(System.IO.TextWriter tw = null, System.Globalization.CultureInfo ci = null, string separator = null, string newLine = null)
        {
            writer = tw ?? System.IO.TextWriter.Null;
            info = ci ?? System.Globalization.CultureInfo.InvariantCulture;
            NewLine = newLine;
            Separator = separator ?? " ";
        }
        public void Print(int num) { writer.Write(num.ToString(info)); }
        public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(long num) { writer.Write(num.ToString(info)); }
        public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(double num) { writer.Write(num.ToString("F12", info)); }
        public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }
        public void Print(string str) { writer.Write(str); }
        public void Print(string format, params object[] arg) { writer.Write(string.Format(info, format, arg)); }
        public void Print<T>(string format, IEnumerable<T> sources) { writer.Write(format, sources.OfType<object>().ToArray()); }
        public void Print(IEnumerable<char> sources) { writer.Write(sources.AsString()); }
        public void Print<T>(IEnumerable<T> sources)
        {
            var res = new System.Text.StringBuilder();
            foreach (var x in sources)
            {
                res.AppendFormat(info, "{0}", x);
                if (string.IsNullOrEmpty(Separator))
                    res.Append(Separator);
            }
            writer.Write(res.ToString(0, res.Length - Separator.Length));
        }
        public void PrintLine() { writer.WriteLine(); }
        public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }
        public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }
        public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(double num) { writer.WriteLine(num.ToString("F12", info)); }
        public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }
        public void PrintLine(string str) { writer.WriteLine(str); }
        public void PrintLine(string format, params object[] arg) { writer.WriteLine(string.Format(info, format, arg)); }
        public void PrintLine<T>(string format, IEnumerable<T> sources) { writer.WriteLine(format, sources.OfType<object>().ToArray()); }
        public void PrintLine<T>(IEnumerable<T> sources)
        {
            var res = new StringBuilder();
            foreach (var x in sources)
            {
                res.AppendFormat(info, "{0}", x);
                if (!string.IsNullOrEmpty(Separator))
                    res.Append(Separator);
            }
            writer.WriteLine(res.ToString(0, res.Length - Separator.Length));
        }
        public void Flush() { writer.Flush(); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream)
        {
            iStream = stream;
        }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool EndOfStream { get { return eof; } }
        private byte readByte()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len)
            {
                ptr = 0;
                len = iStream.Read(buf, 0, 1024);
                if (len <= 0)
                {
                    eof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }
        private bool inSpan(byte c)
        {
            const byte lb = 33, ub = 126;
            return !(c >= lb && c <= ub);
        }
        private byte skip()
        {
            byte b = 0;
            do b = readByte();
            while (!eof && inSpan(b));
            return b;
        }
        public char Char()
        {
            return (char)skip();
        }
        public char[] Char(int n)
        {
            var a = new char[n];
            for (int i = 0; i < n; i++)
                a[i] = (char)skip();
            return a;
        }
        public char[][] Char(int n, int m)
        {
            var a = new char[n][];
            for (int i = 0; i < n; i++)
                a[i] = Char(m);
            return a;
        }
        public string Scan()
        {

            const byte lb = 33, ub = 126;
            if (eof) throw new System.IO.EndOfStreamException();

            do
            {
                while (ptr < len && (buf[ptr] < lb || ub < buf[ptr]))
                {
                    ptr++;
                }
                if (ptr < len)
                    break;
                ptr = 0;
                len = iStream.Read(buf, 0, 1024);
                if (len <= 0)
                {
                    eof = true;
                    return null;
                }
                continue;
            } while (true);

            StringBuilder sb = null;
            do
            {
                var i = ptr;
                while (i < len)
                {
                    if (buf[i] < lb || ub < buf[i])
                    {
                        string s;
                        if (sb != null)
                        {
                            sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                            s = sb.ToString();
                        }
                        else s = new string(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                        ptr = i + 1;
                        return s;
                    }
                    i++;
                }
                i = len - ptr;
                if (sb == null) sb = new StringBuilder(i + 32);
                sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i));
                ptr = 0;
            } while ((len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true;
            return sb.ToString();
        }
        public string[] Scan(int n)
        {
            var a = new string[n];
            for (int i = 0; i < n; i++)
                a[i] = Scan();
            return a;
        }
        public string ScanLine()
        {
            const byte el = 10, cr = 13;
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            do
            {
                var i = ptr;
                while (i < len)
                {
                    if (buf[i] == cr || buf[i] == el)
                    {
                        string s;
                        if (sb != null)
                        {
                            sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                            s = sb.ToString();
                        }
                        else s = new string(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i - ptr));
                        if (buf[i] == cr) i++;
                        if (buf[i] == el) i++;
                        ptr = i;
                        return s;
                    }
                    i++;
                }
                i = len - ptr;
                if (sb == null) sb = new StringBuilder(i + 32);
                sb.Append(System.Text.UTF8Encoding.Default.GetChars(buf, ptr, i));
                ptr = 0;
            } while ((len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true;
            return sb.ToString();
        }
        public double Double()
        {
            return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture);
        }
        public double[] Double(int n)
        {
            var a = new double[n];
            for (int i = 0; i < n; i++)
                a[i] = Double();
            return a;
        }
        public int Integer()
        {
            var ret = 0;
            byte b = 0;
            bool isMynus = false;
            const byte zero = 48, nine = 57, mynus = 45;
            do b = readByte();
            while (!eof && !((b >= zero && b <= nine) || b == mynus));

            if (b == mynus)
            {
                isMynus = true;
                b = readByte();
            }
            while (true)
            {
                if (b >= zero && b <= nine)
                {
                    ret = ret * 10 + b - zero;
                }
                else return isMynus ? -ret : ret;
                b = readByte();
            }

        }
        public int[] Integer(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = Integer();
            return a;
        }
        public long Long()
        {
            long ret = 0;
            byte b = 0;
            bool isMynus = false;
            const byte zero = 48, nine = 57, mynus = 45;
            do b = readByte();
            while (!eof && !((b >= zero && b <= nine) || b == mynus));
            if (b == '-')
            {
                isMynus = true;
                b = readByte();
            }
            while (true)
            {
                if (b >= zero && b <= nine)
                    ret = ret * 10 + (b - zero);
                else return isMynus ? -ret : ret;
                b = readByte();
            }

        }
        public long[] Long(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = Long();
            return a;
        }
        public void Flush()
        {
            iStream.Flush();
        }

    }

}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> source)
        {
            return new string(source.ToArray());
        }
        static public string AsJoinedString<T>(this IEnumerable<T> source, string separator = " ")
        {
            return string.Join(separator, source);
        }
        static public T[] Enumerate<T>(this int n, Func<int, T> selector)
        {
            var res = new T[n];
            for (int i = 0; i < n; i++)
                res[i] = selector(i);
            return res;
        }
    }
}
#endregion


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

namespace razmer_monitora
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine());
            int a = (int)Math.Sqrt(n);
            int b = n/a;
            while (a*b!=n)
            {
                a--;
                b = n / a;
            }
            Console.WriteLine(a+" "+b);
        }
    }
}


using System;

public class Program
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		for (int i = (int)Math.Sqrt(n); i > 0; i--)
		{
			if (n % i == 0)
			{
				Console.WriteLine($"{i} {n / i}");
				return;
			}
		}
	}
}


using System;

class Program
{
	static void Main()
	{
		int n = Convert.ToInt32(Console.ReadLine());
		string inp = Console.ReadLine();
		string[] par = inp.Split(' ');
		int i, d, prognoz;

		int[] a = new int[n];

		for (i = 0; i < n; i++)
			a[i] = Convert.ToInt32(par[i]);

		d = (a[n - 1] - a[0]) / (n - 1);

		for (i = 1; i < n; i++)
		{
			if (a[i] - a[i - 1] != d)
			{
				d = 0;
			}
		}

		/*if (d == a[1] - a[0])
			prognoz = a[n - 1] + d;
		else
			prognoz = a[n - 1];*/

		prognoz = a[n - 1] + d;

		Console.WriteLine("{0}", prognoz);
	}
}


using System;

namespace E
{
    class Program
    {
        static void Main(string[] args)
        {
            int days = int.Parse(Console.ReadLine());
            var _temp = Console.ReadLine().Split(' ');

            bool _flag = true;
            int zeroDay, secondDay, progress, expectedTemp, currTemp = 0;

            zeroDay = int.Parse(_temp[0]);
            secondDay = int.Parse(_temp[1]);

            progress = secondDay - zeroDay;
            if (days >= 3)
            {
                for (int i = 1; i < days; i++)
                {
                    currTemp = int.Parse(_temp[i]);
                    expectedTemp = int.Parse(_temp[i - 1]) + progress;
                    if(currTemp != expectedTemp)
                    {
                        _flag = false;
                        break;
                    }
                }
                if(_flag)
                {
                    Console.WriteLine(currTemp + progress);

                }
                else
                {
                    Console.WriteLine(_temp[days - 1]);
                }

            }
            else
            {
                expectedTemp = zeroDay + progress * (days - 1);

                if (int.Parse(_temp[days - 1]) == expectedTemp)
                {
                    Console.WriteLine(expectedTemp + progress);

                }
                else
                    Console.WriteLine(_temp[days - 1]);
            }

        }
    }
}


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

namespace Lucky_Year
{
    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)
        {
            string s = reader.ReadLine();
            int n = int.Parse(s);

            char[] next = s.ToCharArray();
            string ss;
            for (int i = 1; i < next.Length; i++)
            {
                next[i] = '0';
            }
            if (next[0] < '9')
            {
                next[0]++;
                ss = new string(next);
            }
            else
            {
                next[0] = '0';
                ss = "1" + new string(next);
            }

            writer.WriteLine(long.Parse(ss) - n);
            writer.Flush();
        }
    }
}


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

namespace A808
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string a1 = a + "";
            int l = a1.Length;
            if (l == 1)
            {
                Console.WriteLine(1);
            }
            else {

                int m =int.Parse(a1[0]+"");
                int k = (int)Math.Pow(10, l - 1);
                Console.WriteLine((m+1)* k-a);
            }

        }
    }
}


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.Threading;

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            long n = ReadLong();
            long m = ReadLong();
            long ans = 0;
            for (long i = 1; i <= m; i++)
            {
                for (long j = 1; j <= m; j++)
                {
                    if ((i * i + j * j) % m == 0)
                    {
                        long ci = (n + m - i) / m;
                        long cj = (n + m - j) / m;
                        ans += ci * cj;
                    }
                }
            }
            Writer.WriteLine(ans);
        }

        public static void Solve()
        {
            SolveCase();

            /*var sw = Stopwatch.StartNew();*/

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

            /*sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);*/
        }

        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.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lib
{
    public class DivideCandies
    {
        public static void Main()
        {
            Solve(Console.In, Console.Out);
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            var tokens = tr.ReadLine().Split();
            var n = long.Parse(tokens[0]);
            var m = long.Parse(tokens[1]);

            var t = new long[m, m];

            var res = 0L;
            for (long i = 0; i < m; i++)
            {
                for (long j = 0; j < m; j++)
                {
                    t[i, j] = ((i+1) * (i+1) + (j+1) * (j+1)) % m;
                    if (t[i, j] == 0)
                        res++;
                }
            }

            var p = n / m;
            res *= p * p;

            var r = n % m;

            var res2 = 0L;
            for (long i = 0; i < r; i++)
            {
                for (long j = 0; j < m; j++)
                {
                    if (t[i, j] == 0)
                        res2++;
                }
            }
            res += res2 * p * 2;

            for (long i = 0; i < r; i++)
            {
                for (long j = 0; j < r; j++)
                {
                    if (t[i, j] == 0)
                        res++;
                }
            }

            tw.WriteLine(res);
        }
    }
}


using System;

class Program {
    static void Main()  {
        int n = int.Parse(Console.ReadLine());

        int b = n%3 == 2? n/3 + 1 : n/3;
        int a = b/12;
        b %= 12;

        Console.WriteLine(a + " " + b);
    }
}


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

namespace ConsoleApplication254
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int a = n/36;
            int b = (n-a*36)/3;
            if ((n - a * 36) % 3 == 2) b++;
            if (b == 12) { a++; b = 0; }
            Console.WriteLine(a+" "+b);

        }
    }
}/*using System;
using System.Collections.Generic;
using System.Text;

namespace chislo
{
    class Program
    {
        static void Main(string[] args)
        {int sch = 0;
            string[] s = Console.ReadLine().Split(' ');
            long n = Convert.ToInt64(s[0]);
            long l1 = Convert.ToInt64(s[1]);
            long r1 = Convert.ToInt64(s[2]);
            List<long> l = new List<long>(); if (n == 0) Console.WriteLine(0);
            else
                if (n == 1)
                {
                    if (l1 <= 2 && r1 >= 2) Console.WriteLine(1);
                    else
                        Console.WriteLine(0);
                }
                else
            {
                for (int i = 0; n > 1; i++)
                {
                    l.Add(n); n /= 2;
                }
                string c = Convert.ToString(l[l.Count - 1] / 2);
                string c1 = Convert.ToString(l[l.Count - 1] % 2);
                string str = (c + c1 + c);
                for (int i = l.Count - 2; i >= 0; i--)
                {
                    c1 = Convert.ToString(l[i] % 2);
                    str += c1 + str;
                }
                Console.WriteLine(str);

                /*for (long i = l1 - 1; i < r1; i++)
                {
                    if (str[i] == '1') sch++;
                }
                 Console.WriteLine(str);
                Console.WriteLine(sch);

            }

        }
    }
}*/


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

namespace Alice__Bob__Oranges_and_Apples
{
    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)
        {
            long a = Next();
            long b = Next();

            var r = new StringBuilder();

            while (true)
            {
                if (a > b)
                {
                    if (b != 1)
                        r.Append(a/b);
                    else
                    {
                        r.Append(a/b - 1);
                    }
                    r.Append('A');
                    a %= b;
                }
                else
                {
                    if (a != 1)
                        r.Append(b/a);
                    else
                    {
                        r.Append(b/a - 1);
                    }
                    r.Append('B');
                    b %= a;
                }

                if ((a == 0 || b == 0))
                {
                    if ((a + b) != 1)
                    {
                        writer.WriteLine("Impossible");
                        writer.Flush();
                        return;
                    }
                    break;
                }
            }

            writer.WriteLine(r.ToString());
            writer.Flush();
        }

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


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

namespace Lucky_Sum
{
    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)
        {
            var lucky = new List<long> {4, 7};

            int l = Next();
            int r = Next();

            int first = 0;
            int last = 1;
            long d = 10;
            do
            {
                for (int i = first; i <= last; i++)
                {
                    lucky.Add(d*4 + lucky[i]);
                    lucky.Add(d*7 + lucky[i]);
                }
                d *= 10;
                first = last + 1;
                last = lucky.Count - 1;
            } while (lucky[last] < r);

            long sum = 0;

            lucky.Sort();

            int il = lucky.BinarySearch(l);
            if (il < 0)
                il = ~il;

            int ir = lucky.BinarySearch(r);
            if (ir < 0)
                ir = ~ir;

            if (il == ir)
            {
                sum = lucky[ir]*(r - l + 1);
            }
            else
            {
                sum = lucky[il]*(lucky[il] - l + 1);
                sum += lucky[ir]*(r - lucky[ir - 1]);

                for (int i = il + 1; i < ir; i++)
                {
                    sum += lucky[i]*(lucky[i] - lucky[i - 1]);
                }
            }

            writer.WriteLine(sum);
            writer.Flush();
        }

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

namespace ProgrammingContest.Codeforces.Round91 {
    class A {
        static List<long> num = new List<long>();
        static void gen(long x) {
            if (x <= 10000000000L) {
                num.Add(x);
                gen(x * 10 + 4);
                gen(x * 10 + 7);
            }
        }

        //
        static void Main() {
            var xs = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), int.Parse);
            int a = xs[0],
                b = xs[1];
            gen(0);
            num.Sort();
            long res = 0;
            for (int i = 0; ; i++) {
                if (num[i+1] < a) {
                    continue;
                }
                if (num[i+1] > b) {
                    res += (b - Math.Max(num[i], a-1)) * num[i + 1];
                    break;
                }
                res += (num[i + 1] - Math.Max(num[i], a-1)) * num[i + 1];
            }
            Console.WriteLine(res);
        }
    }
}


using System;
using System.Threading;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
namespace Codeforces
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (Petals(s))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }

        static bool Petals(string landscape)
        {
            string substring = string.Empty;
            var values = new [] {"ABC", "ACB", "BCA", "BAC", "CAB", "CBA"};
            bool result = false;
            for (int i = 0; i < landscape.Length - 2; i++)
            {
                if (landscape.Substring(i, 3).Contains("ABC") || landscape.Substring(i, 3).Contains("ACB") || landscape.Substring(i, 3).Contains("BCA") || landscape.Substring(i, 3).Contains("BAC") || landscape.Substring(i, 3).Contains("CAB") || landscape.Substring(i, 3).Contains("CBA"))
                {
                    result = true;
                    break;
                }
                else
                    result = false;
            }
            return result;
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using static CF.ReadNext;

namespace CF
{
    public static class Program
    {
        private static void Main()
        {
            var s = Console.ReadLine();
            for (int i = 0; i <= s.Length - 3; i++)
            {
                var substring = string.Concat(s.Substring(i, 3).OrderBy(c=>c));
                if (substring == "ABC")
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }

    public static class ReadNext
    {
        public static int NextInt()
        {
            var next = ReadUntilSpace();
            return int.Parse(next);
        }

        public static double NextDouble()
        {
            var next = ReadUntilSpace();
            return double.Parse(next);
        }

        public static string NextWord()
        {
            return ReadUntilSpace();
        }

        private static bool IsWhiteSpace(int n)
        {
            return n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1;
        }

        private static string ReadUntilSpace()
        {
            var result = "";

            var n = Console.Read();
            // read whitespace
            while (IsWhiteSpace(n))
            {
                n = Console.Read();
            }

            // read characters
            while (!IsWhiteSpace(n))
            {
                result += (char)n;
                n = Console.Read();
            }

            return result;
        }
    }
}


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

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

            int counter = 0;
            for (int i = 2; i < A; i++)
                counter += sumOfBase(A, i);

            Console.WriteLine("{0}/{1}", counter / gcd(counter, A-2), (A-2) / gcd(counter, A-2));
        }
        private static int gcd(int a, int b)
        {
            return b == 0 ? a : gcd(b, a % b);
        }
        private static int sumOfBase(int A, int Base)
        {
            int ans = 0;
            while (A > 0)
            {
                ans += A % Base;
                A /= Base;
            }
            return ans;
        }

    }
}


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

namespace CodeForce
{
    class _13a
    {
        public static void Main()
        {
            var line = Console.ReadLine();
            var n = int.Parse(line);
            var sum = 0;
            for (var i = 2; i < n; i++)
            {
                var num = n;
                while (num != 0)
                {
                    sum += num % i;
                    num /= i;
                }
            }
            var low = n - 2;
            for (var i = 2; i < 1010; i++)
            {
                while (low % i == 0 && sum % i == 0)
                {
                    low /= i;
                    sum /= i;
                }
            }
            Console.WriteLine("{0}/{1}", sum, low);
        }
    }
}


using System;

namespace Codeforces
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			new Solution();
		}
	}
	class Solution
	{
		public Solution(){
            int x = int.Parse(Console.ReadLine());
            if (x == 1)
            {
                Console.WriteLine("1");
                return;
            }
            String sx = x.ToString();
            int count = 1;
            for (int i = 1; i <= Math.Sqrt(x); i++)
            {
                char[] si = i.ToString().ToCharArray();
                if (x % i == 0 && sx.IndexOfAny(si) >= 0)
                {
                    count++;
                }
                if (i > 1 && i != x / i && x % (x / i) == 0)
                {
                    char[] ssi = (x / i).ToString().ToCharArray();
                    if(sx.IndexOfAny(ssi)>=0)
                        count++;
                }
            }
            Console.Write(count);
            //Console.ReadKey(true);

		}
	}
}
/*A
int n=int.Parse(Console.ReadLine());
Console.Write(n+" ");
for (int i = 1; i < n; i++)
{
    Console.Write(i + " ");
}
*/

/* B
            int x = int.Parse(Console.ReadLine());
            if (x == 1)
            {
                Console.WriteLine("1");
                return;
            }
            String sx=x.ToString();
            int count=1;
            for (int i = 1; i <= Math.Sqrt(x); i++)
            {
                char[] si=i.ToString().ToCharArray();
                if (x%i==0 && sx.IndexOfAny(si)>=0)
                {
                        count++;
                 }
            }
            Console.Write(count);
            */
/*C
            int n = int.Parse(Console.ReadLine());
            String s=Console.ReadLine();
            String[] z=s.Split(' ');
            int[] c = new int[n];
            for (int i = 0; i < n; i++)
            {
                c[i] = int.Parse(z[i]);
            }
            int count = 0;
            for (int i = 1; i < n; i++)
            {
                if (c[i - 1] > c[i]) count++;
                if (count > 2)
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
            if (count == 2 || count ==0)
            {
                Console.WriteLine("YES");
                return;
            }
            if (count == 1)
            {
                int i=0;
                while (c[i] <= c[i + 1]) i++;
                int p=c[i];
                int t=c[i+1];i++;
                while (i<n && c[i] == t) i++;
                if (i == n)
                {
                    Console.WriteLine("YES");
                    return;
                }
                if (c[i] == p)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            */