using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
//using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

//using System.Threading;

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            /*Random random = new Random();
            for (int kk = 0; kk < 50; kk++)
            {
                for (int i = 0; i < 250; i++)
                {
                    Writer.Write("{0} ", random.Next(201));
                }
                Writer.WriteLine();
            }*/

            int[] a = ReadIntArray();
            int n = a.Length;
            int s = 10; // ???
            // double min = a.Min();
            // double max = a.Max();
            // double d = max - min;
            // min -= d / 2 / n;
            // max += d / 2 / n;

            double p = a.Average();
            //double sum = GetValue(a, s, n, a.Max());
            double mean = a.Average();
            double sum = a.Sum(x => (x - mean) * (x - mean));
            sum /= (a.Max() - a.Min()) * (a.Max() - a.Min());

            int k = s - 3;
            // double X = 2.17;
            double X = 40;

            maxx = Math.Min(maxx, sum);
            // Writer.WriteLine(maxx);
            bool isUniform = sum > 15;
            //Writer.WriteLine(isUniform ? "uniform" : "poisson");
            if (isUniform)
            {
                Writer.WriteLine((a.Min() + a.Max()) / 2);
            }
            else
            {
                //int R = 50;
                //a = a.OrderBy(x => x).Take(a.Length - R).Skip(R).ToArray();
                Writer.WriteLine(((int)Math.Round(a.Average())));
            }
        }

        private static double GetValue(int[] a, int s, int n, double max)
        {
            double min = 0;
            double e = (max - min) / s;

            int[] count = new int[s];
            for (int i = 0; i < n; i++)
            {
                int index = (int)((a[i] - min - 1e-10) / e);
                if (index < 0)
                {
                    index = 0;
                }
                if (index >= s)
                {
                    index = s - 1;
                }
                count[index]++;
            }

            double np = (double)n / s;
            double sum = count.Sum(x => (x - np) * (x - np) / np);
            return sum;
        }

        public static double maxx = double.MaxValue;

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

        public class Point
        {
            public Point(int x, int y)
            {
                X = x;
                Y = y;
            }

            public int X;

            public int Y;

            protected bool Equals(Point other)
            {
                return X == other.X && Y == other.Y;
            }

            public override bool Equals(object obj)
            {
                if (ReferenceEquals(null, obj))
                {
                    return false;
                }
                if (ReferenceEquals(this, obj))
                {
                    return true;
                }
                if (obj.GetType() != this.GetType())
                {
                    return false;
                }
                return Equals((Point)obj);
            }

            public override int GetHashCode()
            {
                unchecked
                {
                    return (X * 397) ^ Y;
                }
            }
        }

        public static class Standard
        {
            public static long Power(long x, long p, long mod)
            {
                long result = 1;
                while (p > 0)
                {
                    if ((p & 1) == 0)
                    {
                        x = (x * x) % mod;
                        p >>= 1;
                    }
                    else
                    {
                        result = (result * x) % mod;
                        p--;
                    }
                }
                return result;
            }

            public static long Gcd(long a, long b)
            {
                return b == 0 ? a : Gcd(b, a % b);
            }

            public static List<int> GetPrimes(int n)
            {
                bool[] isPrime = Enumerable.Repeat(true, n).ToArray();
                isPrime[0] = false;
                isPrime[1] = false;
                for (int i = 2; i < n; i++)
                {
                    if (isPrime[i])
                    {
                        for (int j = i + i; j < n; j += i)
                        {
                            isPrime[j] = false;
                        }
                    }
                }
                List<int> primes = new List<int>();
                for (int i = 0; i < n; i++)
                {
                    if (isPrime[i])
                    {
                        primes.Add(i);
                    }
                }
                return primes;
            }
        }

        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();

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

class Program
{
    static void Main(string[] args)
    {
        int n = RI();
        var next = RIA(n);
        if (next.Distinct().Count() != n)
        {
            Console.Write(-1);
            return;
        }

        bool[] visited = new bool[n];
        List<int> size = new List<int>();
        for (int i = 0; i < n; i++)
            if (!visited[i])
            {
                int cnt = 0;
                int t = i;
                while (!visited[t])
                {
                    visited[t] = true;
                    t = next[t] - 1;
                    cnt++;
                }

                size.Add(cnt);
            }

        long answer = 1;
        for (int i = 0; i < size.Count; i++)
        {
            var sz = (size[i] % 2 == 0) ? (size[i] / 2) : size[i];
            answer = (answer / GCD(answer, sz)) * sz;
        }

        Console.Write(answer);
    }

    private const int Mod = 1000000000 + 7;

    #region Data Read
    private static char ReadSign()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans == '+' || ans == '-' || ans == '?')
                return (char)ans;
        }
    }

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

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

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

        return g;
    }

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

        return matrix;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return s.ToArray();
    }

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

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

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

        return s;
    }

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

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

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

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

        return s.ToArray();
    }

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

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

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

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

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

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

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

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

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

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


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

namespace Test
{
    class IOHelper : IDisposable
    {
        StreamReader reader;
        StreamWriter writer;

        public IOHelper(string inputFile, string outputFile, Encoding encoding)
        {
            StreamReader iReader;
            StreamWriter oWriter;
            if (inputFile == null)
                iReader = new StreamReader(Console.OpenStandardInput(), encoding);
            else
                iReader = new StreamReader(inputFile, encoding);

            if (outputFile == null)
                oWriter = new StreamWriter(Console.OpenStandardOutput(), encoding);
            else
                oWriter = new StreamWriter(outputFile, false, encoding);

            reader = iReader;
            writer = oWriter;

            curLine = new string[] { };
            curTokenIdx = 0;
        }

        string[] curLine;
        int curTokenIdx;

        char[] whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        public string ReadNextToken()
        {
            if (curTokenIdx >= curLine.Length)
            {
                //Read next line
                string line = reader.ReadLine();
                if (line != null)
                    curLine = line.Split(whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    curLine = new string[] { };
                curTokenIdx = 0;
            }

            if (curTokenIdx >= curLine.Length)
                return null;

            return curLine[curTokenIdx++];
        }

        public int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        public double ReadNextDouble()
        {
            var nextToken = ReadNextToken();
            var result = 0.0;
            nextToken = nextToken.Replace(".", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
            result = double.Parse(nextToken);
            return result;
        }

        public void Write(string stringToWrite)
        {
            writer.Write(stringToWrite);
        }

        public void WriteLine(string stringToWrite)
        {
            writer.WriteLine(stringToWrite);
        }

        public void WriteLine(double valueToWrite)
        {
            long intPart = (long)valueToWrite;
            double fracPart = valueToWrite - intPart;
            var fracPartStr = fracPart.ToString();
            if (fracPartStr.Length > 1)
                fracPartStr = fracPartStr.Substring(2);
            var strToWrite = string.Format("{0}.{1}", intPart, fracPartStr);
            writer.WriteLine(strToWrite);
        }

        public void Dispose()
        {
            try
            {
                if (reader != null)
                {
                    reader.Dispose();
                }
                if (writer != null)
                {
                    writer.Dispose();
                }
            }
            catch { };
        }

        public void Flush()
        {
            if (writer != null)
            {
                writer.Flush();
            }
        }
    }

    class Program
    {
        protected IOHelper ioHelper;

        int n;
        string input;
        string output;

        StringBuilder outputBuilder = new StringBuilder();

        public void Solve()
        {
            n = ioHelper.ReadNextInt();
            input = ioHelper.ReadNextToken();

            while(input.Length>0)
            {
                if(input.StartsWith("ogo"))
                {
                    outputBuilder.Append("***");
                    input = input.Substring(3);

                    while(input.StartsWith("go"))
                    {
                        input = input.Substring(2);
                    }
                }
                else
                {
                    outputBuilder.Append(input[0]);
                    input = input.Substring(1);
                }
            }

            output = outputBuilder.ToString();
            ioHelper.WriteLine(output);
            ioHelper.Flush();

            //Console.ReadKey();
        }

        public Program(string inputFile, string outputFile)
        {
            ioHelper = new IOHelper(inputFile, outputFile, Encoding.Default);
            Solve();
            ioHelper.Dispose();
        }

        static void Main(string[] args)
        {
            Program myProgram = new Program(null, null);
        }
    }
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = "";
            input = Console.ReadLine();
            int minutesToSleep = 0;
            string reverseInput = new string(input.ToCharArray().Reverse().ToArray());
            if(reverseInput != input)
            {
                DateTime time = new DateTime();
                DateTime.TryParse(input, out time);
                string newTime = time.ToString("HH:mm");
                string reverseNewTime = new string(newTime.ToCharArray().Reverse().ToArray());
                while(newTime != reverseNewTime)
                {
                    time = time.AddMinutes(1);
                    newTime = time.ToString("HH:mm");
                    reverseNewTime = new string(newTime.ToCharArray().Reverse().ToArray());
                    minutesToSleep++;
                }
            }
            Console.Write(minutesToSleep);
        }
    }
}


/* Date: 25.02.2019 * Time: 21:45 */
//

/*
�	fflush(stdout) � ����� C++;
�	System.out.flush() � Java;
�	stdout.flush() � Python;
�	flush(output) � Pascal;
*/

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

class Example
{
	public static void Main (string[] args)
	{
# if ( ! ONLINE_JUDGE )
		StreamReader sr = new StreamReader ("C:\\TRR\\2019\\Task\\07 Codeforces\\037\\A.TXT");
		StreamWriter sw = new StreamWriter ("C:\\TRR\\2019\\Task\\07 Codeforces\\037\\A.OUT");
# endif

		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

		int n;
		string s;

# if ( ONLINE_JUDGE )
		n = int.Parse (Console.ReadLine ());
		s = Console.ReadLine ();
# else
		n = int.Parse (sr.ReadLine ());
		s = sr.ReadLine ();
		sw.WriteLine ("*** n = " + n);
		sw.WriteLine ("*** a = " + s);
# endif

		int [] a = new int [n];
		string [] ss = s.Split (' ');
		int kp = 0, kn = 0;
		for ( int i=0; i < n; i++ )
		{
			a [i] = int.Parse (ss [i]);
			if ( a [i] > 0 )
				kp ++;
			else if ( a [i] < 0 )
				kn ++;
		}

		int d = 0;
		if ( kp >= n - kp )
			d = 1;
		if ( kn >= n - kn )
			d = -1;

# if ( ONLINE_JUDGE )
		Console.WriteLine (d);
# else
		sw.WriteLine (d);
		sw.Close ();
# endif

	}
}


using System;

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

            int[] n = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int price = n[0];
            int counter = 0;
            for (counter = 1; ; counter++)
            {
                if (price % 10 == 0)
                {
                    break;
                }
                else if (price % 10 - n[1] == 0) break;

                price = n[0] * (counter + 1);
            }
            Console.WriteLine(counter);
        }
    }
}


// A Dynamic Programming based
// C# program to find minimum
// number operations to
// convert str1 to str2
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{

    public static void Main()
    {
        List<ulong> arr = Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToList<ulong>();
        var op = Console.ReadLine().Split(' ').ToArray();
        Console.Write(SmallestNumber(arr, op, 0, ulong.MaxValue));
    }

    public static ulong SmallestNumber(List<ulong> arr, string[] ope, int opeCount, ulong min)
    {

        if (arr.Count == 1)
            return arr[0];

        for (int i = 0; i < arr.Count; i++)
        {
            for (int j = i + 1; j < arr.Count; j++)
            {
                if (ope[opeCount] == "+")
                {
                    var listNew = new List<ulong>(arr);
                    var tmp = listNew[i] + listNew[j];
                    listNew.RemoveAt(j);
                    listNew.RemoveAt(i);
                    listNew.Add(tmp);
                    min = Math.Min(min, SmallestNumber(listNew, ope, opeCount + 1, min));
                }
                if (ope[opeCount] == "*")
                {
                    var listNew = new List<ulong>(arr);
                    var tmp = listNew[i] * listNew[j];
                    listNew.RemoveAt(j);
                    listNew.RemoveAt(i);

                    listNew.Add(tmp);
                    min = Math.Min(min, SmallestNumber(listNew, ope, opeCount + 1, min));
                }
            }
        }

        //min = Math.Min(min1, min2);
        return min;
    }
}


using System;
using System.Linq;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = a[0]-1; i > a[0]-1-a[1]; i--)
            {
                b[i] = a[2];
            }

            Console.WriteLine(b.Sum());
        }
    }
}


using System;
// you can also use other imports, for example:
using System.Collections.Generic;
using System.Linq;
using System.IO;

public class HelloWorld
{

    public static void Main(string[] args)
    {
        var n = Convert.ToInt64(Console.ReadLine());
        Console.WriteLine(n / 2520);
    }

}


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

public class Program
{
    public static void Main() {
        int[] arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int y = arr[0]+1;
        int b = arr[1];
        int r = arr[2]-1;

        Console.WriteLine(Math.Min(Math.Min(r,b),y)*3);
    }
}


using System;
using CompLib.Mathematics;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int m = sc.NextInt();

        var ans = ModInt.Pow(ModInt.Pow(2, m) - 1, n);
        Console.WriteLine(ans);
    }

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

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

// 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;

        /// <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
}


using System;
using System.IO;
using System.Collections.Generic;
using System.Numerics;

namespace cf420
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_cf420B();
        }

        public static void solve_cf420B()
        {
            long[] mb = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            long m = mb[0];
            long b = mb[1];

            List<KeyValuePair<long, long>> xy = new List<KeyValuePair<long, long>>();

            for (long x = 0; x < (m * b) + 1; x++)
            {
                long xm = x / m;
                if (x % m == 0)
                {
                    xy.Add(new KeyValuePair<long, long>(x, -xm + b));
                }
            }

            long max = -1;
            for (int i = 0; i < xy.Count; i++)
            {
                long l = Math.Min(xy[i].Key, xy[i].Value);
                long n = Math.Max(xy[i].Key, xy[i].Value);

                long sum = 0;

                for (long j = 0; j <= l; j++)
                {
                    sum += ((n + 1) * (j + n + j)) / 2;
                }
                max = Math.Max(max, sum);
            }

            Console.WriteLine(max);
        }
    }
}


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

    public class Given_Length_and_Sum_of_Digits
    {
        public static bool Can(int m, int s)
        {
            if (m == 0)
            {
                return s == 0;
            }
            return s >= 0 && s <= m * 9;
        }
        public static string Calculate(int m, int s)
        {
            var max = "";
            var min = "";

            if (!Can(m, s) || (s==0 && m!=1))
            {
                return "-1 -1";
            }
            var currentS = s;
            while (min.Length != m)
            {
                for(var i = 0; i <= 9; i++)
                {
                    if(min.Length ==0 && i == 0 && m!=1)
                    {
                        continue;
                    }

                    if(Can(m - min.Length - 1, currentS - i))
                    {
                        min += i.ToString();
                        currentS -= i;
                        break;
                    }
                }
            }
            currentS = s;
            while (max.Length != m)
            {
                for (var i = 9; i >= 0; i--)
                {
                    if (max.Length == 0 && i == 0 && m != 1)
                    {
                        continue;
                    }

                    if (Can(m - max.Length - 1, currentS - i))
                    {
                        max += i.ToString();
                        currentS -= i;
                        break;
                    }
                }
            }

            return min.ToString() + " " + max.ToString();
        }
        public static void Main()
        {
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(Calculate(a[0], a[1]));
        }
}


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

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

                     int numberOfCards = Convert.ToInt32(Console.ReadLine());
                    int inputNumberCard = 0;
                    List<int> Cards = new List<int>();
                    List<int> Temp = new List<int>();
                    for (int i = 0; i < numberOfCards; i++)
                    {
                    inputNumberCard = Convert.ToInt32(Console.ReadLine());
                    Cards.Add(inputNumberCard);
                    }
                    foreach (var el in Cards.Distinct())
                    {
                     Temp.Add(Cards.Where(s => s == el).Count());
                    }
            if ((numberOfCards-Temp[0]) == Temp[0])
                    {
            var x = SearchDuplicateInList(Cards);
                if (x.Count == 2 && x[0] != x[1])
                    {
                    Console.WriteLine("YES");
                    Console.Write($"{x[0]} {x[1]}");
                    }
                    else
                    { Console.WriteLine("NO");}
                    }
                    else
                    { Console.WriteLine("NO"); }
         }
        static List<int> SearchDuplicateInList(List<int> list)
        {
            List<int> result = new List<int>();
            foreach (var s in list)
            {
                if (!result.Contains(s))
                    result.Add(s);
            }
            return result;
        }

   }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nums = Console.ReadLine().Split();
            int n,c,max;
            n = Convert.ToInt32(nums[0]);
            c = Convert.ToInt32(nums[1]);
            nums = Console.ReadLine().Split();
            int[] ar=new int[n];
            int[] m = new int[n];
            for (int i = 0; i < n; i++)
                ar[i] = Convert.ToInt32(nums[i]);
            for (int i = 0; i < n-1; i++)
                m[i] = ar[i] - ar[i + 1] - c;

            max=m[0] ;
            for (int i = 0; i < n; i++)

                if (m[i] > max)
                    max = m[i];
            Console.WriteLine(max);
            Console.ReadLine();

        }
    }
}