using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemA
    {
        static bool SAIKI = false;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var t = NN;
            for (var i = 0;i < t;i++) {
                var n = NN;
                var aList = NNList(n).OrderBy(e => e).ToArray();
                var ok = true;
                for (var j = 1;j < n;j++) {
                    if(Abs(aList[j-1] - aList[j]) <= 1) {

                    }else {
                        ok = false;
                        break;
                    }
                }
                if(ok)Console.WriteLine("YES");
                else Console.WriteLine("NO");
            }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[1024];
        int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return isEof; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (isEof) throw new EndOfStreamException();
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 1024)) <= 0)
                {
                    isEof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int times = Convert.ToInt32(Console.ReadLine());
            int length = 0;
            int[] numbers;
            List<string> results = new List<string>();
            int dif = 0;
            bool canRemove = true;

            for (int i = 0; i < times; i++)
            {
                length = Convert.ToInt32(Console.ReadLine());
                var ns = Console.ReadLine();
                //if(i == 50)
                //    Console.WriteLine("51: " + ns);
                var list = ns.Split(' ').Select(int.Parse).ToList();
                list.Sort();
                numbers = list.ToArray();

                for (int j = 0; j < length - 1; j++)
                {
                    dif = Math.Abs(Convert.ToInt32(numbers[j]) - Convert.ToInt32(numbers[j + 1]));
                    if (dif > 1)
                        canRemove = false;
                }

                results.Add(canRemove ? "YES" : "NO");
                canRemove = true;
            }

            for (int i = 0; i < results.Count; i++)
                Console.WriteLine(results[i]);
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int times = Convert.ToInt32(Console.ReadLine());
            int length = 0;
            string[] numbers;
            List<string> results = new List<string>();
            int dif = 0;
            bool canRemove = true;

            for (int i = 0; i < times; i++)
            {
                length = Convert.ToInt32(Console.ReadLine());
                var ns = Console.ReadLine();
                if(i == 50)
                    Console.WriteLine(ns);
                var list = ns.Split(' ').ToList();
                list.Sort();
                numbers = list.ToArray();

                for (int j = 0; j < length - 1; j++)
                {
                    dif = Math.Abs(Convert.ToInt32(numbers[j]) - Convert.ToInt32(numbers[j + 1]));
                    if (dif > 1)
                        canRemove = false;
                }

                results.Add(canRemove ? "YES" : "NO");
                canRemove = true;
            }

            //for (int i = 0; i < results.Count; i++)
            //    Console.WriteLine(results[i]);
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int times = Convert.ToInt32(Console.ReadLine());
            int length = 0;
            string[] numbers;
            List<string> results = new List<string>();
            int dif = 0;
            bool canRemove = true;

            for (int i = 0; i < times; i++)
            {
                length = Convert.ToInt32(Console.ReadLine());
                var ns = Console.ReadLine();
                if(i == 50)
                    Console.WriteLine("51: " + ns);
                var list = ns.Split(' ').ToList();
                list.Sort();
                numbers = list.ToArray();

                for (int j = 0; j < length - 1; j++)
                {
                    dif = Math.Abs(Convert.ToInt32(numbers[j]) - Convert.ToInt32(numbers[j + 1]));
                    if (dif > 1)
                        canRemove = false;
                }

                results.Add(canRemove ? "YES" : "NO");
                canRemove = true;
            }

            for (int i = 0; i < results.Count; i++)
                Console.WriteLine(results[i]);
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int times = Convert.ToInt32(Console.ReadLine());
            int length = 0;
            string[] numbers;
            List<string> results = new List<string>();
            int dif = 0;
            bool canRemove = true;

            for (int i = 0; i < times; i++)
            {
                length = Convert.ToInt32(Console.ReadLine());
                var list = Console.ReadLine().Split(' ').ToList();
                list.Sort();
                numbers = list.ToArray();

                for (int j = 0; j < length - 1; j++)
                {
                    dif = Math.Abs(Convert.ToInt32(numbers[j]) - Convert.ToInt32(numbers[j + 1]));
                    if (dif > 1)
                        canRemove = false;
                }

                results.Add(canRemove ? "YES" : "NO");
                canRemove = true;
            }

            for (int i = 0; i < results.Count; i++)
                Console.WriteLine(results[i]);
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int times = Convert.ToInt32(Console.ReadLine());
            int length = 0;
            string[] numbers;
            List<string> results = new List<string>();
            int dif = 0;
            bool canRemove = true;

            for (int i = 0; i < times; i++)
            {
                length = Convert.ToInt32(Console.ReadLine());
                numbers = Console.ReadLine().Split(' ');

                for (int j = 0; j < length - 1; j++)
                {
                    dif = Math.Abs(Convert.ToInt32(numbers[j]) - Convert.ToInt32(numbers[j + 1]));
                    if (dif > 1)
                        canRemove = false;
                }

                results.Add(canRemove ? "YES" : "NO");
                canRemove = true;
            }

            for (int i = 0; i < results.Count; i++)
                Console.WriteLine(results[i]);
        }
    }
}


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

namespace ContestTemplateStartUp
{
    class ProgramA_
    {

        static void Main(string[] args)
        {
            var results = new List<long>();
            foreach (var test in Enumerable.Range(0, GetIntFromReadLine()))
            {
                var n = GetInt();
                var a = ReadArray(n);
                Array.Sort(a);
                var res = true;
                for(var index = 0; index < n - 1; ++index)
                {
                    if(a[index + 1] - a[index] > 1)
                    {
                        res = false;
                        break;
                    }
                }
                results.Add(res ? 1 : 0);
            }

            foreach (var result in results)
            {
                Console.WriteLine(result == 1 ? "YES" : "NO");
            }
        }

        //static void Main(string[] args)
        //{
        //    var results = new List<long>();
        //    foreach (var test in Enumerable.Range(0, GetIntFromReadLine()))
        //    {
        //        var n = (long)GetInt();
        //        var r = (long)GetInt();
        //        var min = (long)Math.Min(r, n - 1);
        //        var sum = min * (min + 1) / 2L;
        //        if (r >= n)
        //        {
        //            sum += +1;
        //        }
        //        results.Add(sum);
        //    }

        //    foreach (var result in results)
        //    {
        //        Console.WriteLine(result);
        //    }
        //}

        //static void Main(string[] args)
        //{
        //    var results = new List<long>();
        //    foreach (var test in Enumerable.Range(0, GetIntFromReadLine()))
        //    {
        //        var n = GetInt();
        //        results.Add(n - (n/2));
        //    }

        //    foreach (var result in results)
        //    {
        //        Console.WriteLine(result);
        //    }
        //}

        static long lower_bound(int h, int c, int t)
        {
            long l = 1;
            long r = int.MaxValue;
            while (l + 1 < r)
            {
                long mid = (r + l) / 2;
                if (mid*h+(mid-1)*c >= t*(2*mid-1))
                {
                    l = mid;
                }
                else
                {
                    r = mid;
                }
            }
            return r;
        }

        private static int[] GetPrimes(int n)
        {
            var list = new List<int>();
            while (true)
            {
                var del = GetMinDel(n);
                if (del == 1)
                {
                    break;
                }
                list.Add(del);
                n = n / del;
            }
            return list.ToArray();
        }

        private static int GetMinDel(int n)
        {
            for (long index = 2; index * index <= n; ++index)
            {
                if (n % index == 0)
                {
                    return (int)index;
                }
            }
            return n;
        }

        public static bool Success(int[] chet, int[] nechet)
        {
            foreach (var ch in chet)
                foreach (var nch in nechet)
                {
                    if (Math.Abs(ch - nch) == 1)
                    {
                        return true;
                    }
                }
            return false;
        }

        static int GetInt()
        {
            int integer = 0;
            int n = Console.Read();
            while (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
                n = Console.Read();
            while (n >= '0' && n <= '9')
            {
                integer = integer * 10 + n - '0';
                n = Console.Read();
            }
            return integer;
        }
        static long GetLong()
        {
            long integer = 0;
            int n = Console.Read();
            while (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
                n = Console.Read();
            while (n >= '0' && n <= '9')
            {
                integer = integer * 10 + n - '0';
                n = Console.Read();
            }
            return integer;
        }

        static int[] ReadArray(int count)
        {
            int[] arr = new int[count];
            for (var index = 0; index < count; ++index)
            {
                arr[index] = GetInt();
            }
            return arr;

        }

        static int[] ReadArrayFromReadLine()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }

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

        public static int GetPower_(int num, int power)
        {
            if (power == 0) return 1;
            if (power == 1) return num;
            var prev = GetPower_(num, power / 2);
            var prev2 = ((long)prev * prev);
            if (power % 2 != 0) return (int)((prev2 * num));
            return (int)prev2;
        }
    }
}


//using MetadataExtractor;
//using MetadataExtractor.Formats.Exif;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces
{
    public static class MainClass
    {

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

        static void ReadInt(ref int a)
        {
            a = ReadIntArrayLine()[0];
        }

        static void ReadInts(ref int a, ref int b)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1];
        }

        static void ReadInts(ref int a, ref int b, ref int c)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];
        }

        static int[] ReadIntArrayLine()
        {
            char[] sep = { ' ' };
            return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static void PrintLn(object obj)
        {
            Console.WriteLine(obj.ToString());
        }

        /*public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }*/

        public static void PrintLnCollection<T>(IEnumerable<T> col)
        {
            PrintLn(string.Join(" ", col));
        }

        public static void PrintLn(params object[] v)
        {
            PrintLnCollection(v);
        }

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

        public static string MySubstring(this string str, int start, int finish)
        {
            if (start > finish) return "";
            return str.Substring(start, finish - start + 1);
        }

        public static string Reverse(this string str)
        {
            if (str == null) return null;

            return new string(str.ToArray().Reverse().ToArray());
        }
        public static bool IsInRange(this int a, int lb, int ub)
        {
            return (a >= lb) && (a <= ub);
        }

        private static void mergeDS(int i, int j, int[] a)
        {
            int t = a[j];
            for (int ii = 0; ii < a.Length; ii++)
            {
                if (a[ii] == t)
                    a[ii] = a[i];
            }
        }

        private static T MyMax<T>(params T[] a)
        {
            return a.Max();
        }

        private static T MyMin<T>(params T[] a)
        {
            return a.Min();
        }

        private static int[] GetPrimesLessThan(int x)
        {
            if (x < 2)
                return new int[0];

            int[] a = new int[x];

            a[0] = 1; a[1] = 1;

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    for (int j = 2 * i; j < a.Length; j += i)
                    {
                        a[j] = 1;
                    }
            }

            var abc = new List<int>(x);

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    abc.Add(i);
            }

            return abc.ToArray();
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target == a[mid])
                return mid;
            else if (target < a[mid])
                return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindNearestLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int target)
        {
            return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

        private static int FindRightMostLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target < a[mid])
                return FindRightMostLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindRightMostLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindRightMostLEQElementInTheArray(int[] a, int target)
        {
            return FindRightMostLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

        private static int gcd(int a, int b)
        {
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        //----------------------------------------------------------------------------

        static string GetSha1(string filePath)
        {
            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            using (BufferedStream bs = new BufferedStream(fs))
            {
                using (SHA1Managed sha1 = new SHA1Managed())
                {
                    byte[] hash = sha1.ComputeHash(bs);
                    StringBuilder formatted = new StringBuilder(2 * hash.Length);
                    foreach (byte b in hash)
                    {
                        formatted.AppendFormat("{0:X2}", b);
                    }

                    return formatted.ToString();
                }
            }
        }

        static bool canFit(int a1, int b1, int a2, int b2)
        {
            int[] r1 = { a1, b1 };
            int[] r2 = { a2, b2 };

            Array.Sort(r1);
            Array.Sort(r2);

            bool ans = (r1[0] <= r2[0]) && (r1[1] <= r2[1]);

            return ans;

        }

        class Pair
        {
            public int first { get; set; }
            public int second { get; set; }
        }

        class Coord
        {
            public int x;
            public int y;
            public double d;
        }

        public static double dist(int x1, int y1, int x2, int y2)
        {
            int dx = x2 - x1;
            int dy = y2 - y1;

            return Math.Sqrt(dx * dx + dy * dy);

        }
        static void Main(string[] args)
        {
            int t = ReadIntLine();

            for (int i = 0; i < t; i++)
            {
                int n = ReadIntLine();

                var a = ReadIntArrayLine();

                if (n == 1)
                {
                    PrintLn("YES");
                    continue;
                }

                Array.Sort(a);
                bool isgood = true;
                for (int j = 1; j < a.Length; j++)
                {
                    if (Math.Abs(a[j] - a[j - 1]) > 1)
                    {
                        isgood = false;
                        break;
                    }
                }

                if (isgood)
                    PrintLn("YES");
                else
                    PrintLn("NO");

            }

        }

    }

}


use std::error::Error;
use std::io::{self, Read};
type Result<T> = std::result::Result<T, Box<dyn Error>>;
fn main() -> Result<()> {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input)?;
    let mut lines = input.lines();
    let test_cases: i32 = lines.next().unwrap().parse()?;
    for i in 0..test_cases{
        // let n: i
    }
    Ok(())
}


use std::error::Error;
use std::io::{self, Read};
type Result<T> = std::result::Result<T, Box<dyn Error>>;
fn main() -> Result<()> {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input)?;
    let mut lines = input.lines();
    let test_cases: i32 = lines.next().unwrap().parse()?;
    for i in 0..test_cases {
        let n: i32 = lines.next().unwrap().parse()?;
        let mut arr: Vec<i32> = lines
            .next()
            .unwrap()
            .split_whitespace()
            .map(|s| s.parse::<i32>().unwrap())
            .collect();
        arr.sort();
        let mut len = arr.len();
        for i in 1..arr.len() {
            if !(arr[i] - arr[i - 1] > 1) {
                len -= 1;
            }
        }
        println!(
            "{}",
            match len == 1 {
                true => "YES",
                false => "NO",
            }
        );
    }
    Ok(())
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ps push
#define pf push_front
#define mp make_pair
#define And &&
#define Or ||
#define inf INT_MAX
#define sz(name) name.size()
#define len(name) name.length()
#define ig cin.ignore()
#define sc(name) scanf("%d",&name)
#define ssc(name1,name2) scanf("%d%d",&name1,&name2)
#define sssc(name1,name2,name3) scanf("%d%d%d",&name1,&name2,&name3)
#define scl(name) scanf("%lld",&name)
#define sscl(name1,name2) scanf("%lld%lld",&name1,&name2)
#define ssscl(name1,name2,name3) scanf("%lld%lld%lld",&name1,&name2,&name3)
#define Sort(name) sort(name.begin(),name.end())
#define For(name,start,finish) for(int name=start;name<finish;name++)
#define Forr(name,start,finish) for(int name=start;name>=finish;name--)
#define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//int row[]={-1,0,1,0};
//int col[]={0,1,0,-1};

const ll N=2e5+10;
const ll M=1e9+7;
const ll Z=1e9+9;
const ll base=131;

ll logx(ll a,ll bs){return log(a)/log(bs);}
ll Max(ll a,ll b){if(a>b)return a;return b;}
ll Min(ll a,ll b){if(a>b)return b;return a;}
ll big_mul(ll a,ll b,ll m){ll x=0,y=a%m;while(b>0){if(b&1)x=(x+y)%m;y=(2*y)%m;b>>=1;}return x%m;}
ll big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=(x*y)%m;y=(y*y)%m;b>>=1;}return x%m;}
ll Big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=big_mul(x,y,m);y=big_mul(y,y,m);b>>=1;}return x%m;}
ll mod_inverse(ll a,ll m){return big_mod(a,m-2,m);}  //a^-1 mod m = a^(m-2) mod m

vector<int> pos(N);
vector<int> vec;

int main()
{

    fast_in_out;

    int n;
    cin>>n;

    vector<int> vec(n+10);
    vec[1]=1;
    vec[n]=n*n;

    For(i,2,n)
    vec[i]=vec[i-1]+n;

    For(i,0,n)
    {

        For(j,1,n+1)
            cout<<vec[j]<<" ";

        For(j,1,n)
        vec[j]++;

        vec[n]--;

        cout<<endl;
    }

    return 0;

}

/*

*/


#include <bits/stdc++.h>
#define forr(i,a,b) for( int i=(a) ; i<=(b) ; ++i)
#define ford(i,a,b) for( int i=(a) ; i>=(b) ; --i)
#define ll long long
#define pii pair<long long ,long long>
#define mp make_pair
#define f first
#define s second
#define task "1236C"
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
//forr(i,1,n)
//{
//    forr(j,1,n) cout<< a[i][j] << " " ;
//    cout<< endl;
//}
//cout<< endl;

using namespace std;

const long long mod=1e9+7;
const long pp=400;
string S,X;
int n,m,Qtion;
long long sum,ans ;
vector<int> a[pp] ;
int getbit(int bit,int ii)
{
    return (bit>>ii)&1;
}

void dowork()
{
    cin>>n;
    forr(i,1,n)
    {
        if(i%2==1)
        {
            forr(j,1,n) a[j].push_back((i-1)*n+j);
        }else
        {
            ford(j,n,1) a[n-j+1].push_back((i-1)*n+j);
        }
    }
    forr(i,1,n)
    {
        forr(j,0,n-1) cout <<a[i][j] << " " ;
        cout<< endl;
    }
}

void openmain()
{
    ios_base::sync_with_stdio(0);
    freopen( task".inp" , "r" , stdin );
    freopen( task".out" , "w" , stdout );
    cout.tie();
}

int main()
{

    dowork();
    return 0;
}


#include <bits/stdc++.h>
#define forr(i,a,b) for( int i=(a) ; i<=(b) ; ++i)
#define ford(i,a,b) for( int i=(a) ; i>=(b) ; --i)
#define ll long long
#define pii pair<long long ,long long>
#define mp make_pair
#define f first
#define s second
#define task "1236C"
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
//forr(i,1,n)
//{
//    forr(j,1,n) cout<< a[i][j] << " " ;
//    cout<< endl;
//}
//cout<< endl;

using namespace std;

const long long mod=1e9+7;
const long pp=400;
string S,X;
int n,m,Qtion;
long long sum,ans ;
vector<int> a[pp] ;
int getbit(int bit,int ii)
{
    return (bit>>ii)&1;
}

void dowork()
{
    cin>>n;
    forr(i,1,n)
    {
        if(i%2==1)
        {
            forr(j,1,n) a[j].push_back((i-1)*n+j);
        }else
        {
            ford(j,n,1) a[n-j+1].push_back((i-1)*n+j);
        }
    }
    forr(i,1,n)
    {
        forr(j,0,n-1) cout <<a[i][j] << " " ;
        cout<< endl;
    }
}

void openmain()
{
    ios_base::sync_with_stdio(0);
    freopen( task".inp" , "r" , stdin );
    freopen( task".out" , "w" , stdout );
    cout.tie();
}

int main()
{
  =
    dowork();
    return 0;
}


#include <bits/stdc++.h>
#define forr(i,a,b) for( int i=(a) ; i<=(b) ; ++i)
#define ford(i,a,b) for( int i=(a) ; i>=(b) ; --i)
#define ll long long
#define pii pair<long long ,long long>
#define mp make_pair
#define f first
#define s second
#define task "1236C"
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
//forr(i,1,n)
//{
//    forr(j,1,n) cout<< a[i][j] << " " ;
//    cout<< endl;
//}
//cout<< endl;

using namespace std;

const long long mod=1e9+7;
const long pp=400;
string S,X;
int n,m,Qtion;
long long sum,ans ;
vector<int> a[pp] ;
int getbit(int bit,int ii)
{
    return (bit>>ii)&1;
}

void dowork()
{
    cin>>n;
    forr(i,1,n)
    {
        if(i%2==1)
        {
            forr(j,1,n) a[j].push_back((i-1)*n+j);
        }else
        {
            ford(j,n,1) a[j].push_back((i-1)*n+j);
        }
    }
    forr(i,1,n)
    {
        forr(j,0,n-1) cout <<a[i][j] << " " ;
        cout<< endl;
    }
}

void openmain()
{
    ios_base::sync_with_stdio(0);
    freopen( task".inp" , "r" , stdin );
    freopen( task".out" , "w" , stdout );
    cout.tie();
}

int main()
{

    dowork();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<vector<ll>> res(n, vector<ll>(n));
    for (ll i = 0, k = 0; i < n; i++) {
        for (ll j = 0; j < n; j++, k++) {
            res[i][(j - i + n) % n] = k;
        }
    }
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            cout << res[j][i]+1 << " ";
        }
        cout << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<vector<ll>> res(n);
    for (ll j = 0, k = n*n-1; j < k;) {
        for (ll i = 0; i < n; i++) {
            res[i].push_back(j);
            j++;
            if (sz(res[i]) < n) {
                res[i].push_back(k);
                k--;
            }
        }
    }
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            cout << res[i][j]+1 << " ";
        }
        cout << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using ll = long long;
using ld = long double;

constexpr ll mod = 1000000007;

ll powMod(ll a, ll b, ll n) {
	ll res = 1;
	while (b > 0) {
		if (b & 1) res = (a * res) % n;
		a = (a * a) % n;
		b /= 2;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n;
	cin >> n;
	vector<vector<ll>> res(n, vector<ll>(n));
	for (ll i = 0, k = 0; i < n; i++) {
		for (ll j = 0; j < n; j++, k++) {
			res[i][(i + j) % n] = k;
		}
	}
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n; j++) {
			cout << res[j][i]+1 << " ";
		}
		cout << endl;
	}
	/*ll n, m, k;
	cin >> n >> m >> k;
	vector<vector<ll>> rows(n), cols(m);
	for (ll i = 0; i < k; i++) {
		ll x, y;
		cin >> x >> y;
		x--;
		y--;
		rows[x].push_back(y);
		cols[y].push_back(x);
	}
	ll seen = 1;
	for (auto& v : rows) sort(all(v));
	for (auto& v : cols) sort(all(v));
	ll l = 0;
	ll r = m - 1;
	ll u = 0;
	ll d = n - 1;

	ll x = 0;
	ll y = 0;
	ll dir = 0;
	while (l <= r && u <= d) {
		if (dir == 0) {
			ll nx = r;
			auto it = upper_bound(all(rows[y]), x);
			if (it != rows[y].end()) nx = min(nx, *it - 1);
			u = max(u, y + 1);
			if (nx == x) break;
			seen += abs(x - nx);
			x = nx;
		} else if (dir == 1) {
			ll ny = d;
			auto it = upper_bound(all(cols[x]), y);
			if (it != cols[x].end()) ny = min(ny, *it - 1);
			r = min(r, x - 1);
			if (ny == y) break;
			seen += abs(ny - y);
			y = ny;
		} else if (dir == 2) {
			ll nx = l;
			auto it = upper_bound(all(rows[y]), x);
			if (it != rows[y].begin()) nx = max(nx, *prev(it) + 1);
			d = min(d, y - 1);
			if (nx == x) break;
			seen += abs(x - nx);
			x = nx;
		} else {
			ll ny = u;
			auto it = upper_bound(all(cols[x]), y);
			if (it != cols[x].begin()) ny = max(ny, *prev(it) + 1);
			l = min(l, x + 1);
			if (ny == y) break;
			seen += abs(y - ny);
			y = ny;
		}
		dir++;
		dir %= 4;
	}
	cout << (seen == n*m-k ? "Yes" : "No") << endl;*/
}


#include<bits/stdc++.h>

using namespace std;

int main()
{

    long n;
    cin>>n;
    long a=n*n;
    long arr[n][n];
   long p=1;
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
       { for(int j=0;j<n;j++)
        {

            arr[j][i]=p++;
        }

       }
       else
       {
            for(int j=n-1;j>=0;j--)
        {

            arr[j][i]=p++;
        }
       }
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>

using namespace std;

int main()
{

    long n;
    cin>>n;
    long a=n*n;
    long arr[n][n];
   long p=1;
    for(int i=0;i<n;i++)
    {
        if(p%2==0)
       { for(int j=0;j<n;j++)
        {

            arr[j][i]=p++;
        }

       }
       else
       {
            for(int j=n-1;j>=0;j--)
        {

            arr[j][i]=a--;
        }
       }
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>

using namespace std;

int main()
{

    long n;
    cin>>n;
    long a=n*n;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{

    int tc,o;
    cin>>tc;
    //scanf("%d",&tc);
    int lp,kk,r,s,tt;
    for(lp=tc;lp>=1;lp--)
    {
        for(kk=1;kk<=tc;kk++)
        {
            tt=lp+(kk-1)*tc;
            printf("%d ",tt);
        }
        printf("\n");
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{

    int tc,o;
    cin>>tc;
    //scanf("%d",&tc);
    int lp,kk,r,s,tt;
    for(lp=1;lp<=tc;lp++)
    {
        for(kk=1;kk<=tc;kk++)
        {
            tt=lp+(kk-1)*tc;
            printf("%d ",tt);
        }
        printf("\n");
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{

    int tc,o;
    cin>>tc;
    //scanf("%d",&tc);
    int lp,kk,r,s,tt;
    for(lp=tc*tc;lp>=1;lp--)
    {
        cout<<lp<<" ";

        if(lp%tc==1)
            cout<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

 int main(){
    int n;
    cin>>n;
    int p;
    int q=n*n+1;
    for(int i=1;i<=n;i++){
        q--;
        p=q;
        for(int i=1;i<=n;i++){
            cout<<p<<" ";
            p-=n;
        }
        cout<<endl;
        }}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

 int main(){
    int n;
    cin>>n;
    int p=n*n+1;
    for(int i=1;i<=n;i++){
        for(int i=1;i<=n;i++){
            p--;
            cout<<p<<" ";
        }
        cout<<endl;
        }}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

 int main(){
    int n;
    cin>>n;
    int p;
    int q=0;
    for(int i=1;i<=n;i++){
        q++;
        p=q;
        for(int i=1;i<=n;i++){
            cout<<p<<" ";
            p+=n;
        }
        cout<<endl;
        }}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

 int main(){
    int n;
    cin>>n;
    int arr[n][n];
    int p=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i%2==0)
            {arr[i][j]=p;
            p++;}
            else{
                arr[i][n-j-1]=p;
                p++;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<arr[j][i]<<" ";
        }
        cout<<endl;
    }
        }


#include<bits/stdc++.h>
#define ll long long
#define S second
#define F first

using namespace std;

const ll N = 2e6+5, mod = 1e9 + 7, mod1 = mod-1;

int main()
{
    int n, nn;
    scanf("%d", &n);
    nn = n*n;
    int st = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        st = i-1;
        for(int j = 0 ; j < n ; j++)
        {
            cout << j * n + st + 1 <<" " ;
            st = (st - 1 + n) % n;
            st %= n;
        }cout<<endl;
    }
}


#include<bits/stdc++.h>
#define ll long long
#define S second
#define F first

using namespace std;

const ll N = 2e6+5, mod = 1e9 + 7, mod1 = mod-1;

vector<int> v[305];

int main()
{
    int n, e, s;
    cin>>n;
    e = n*n, s = 1;
    for(int i = 1 ; i <= n ; i++)
    {
        for(int j = 1 ; j < n ; j+=2)
        {
            v[i].push_back(s++);
            v[i].push_back(e--);
        }
    }
    for(int i = 1 ; i <= n ; i++)
    {
        for(auto j:v[i]) cout<<j<<" ";
        if(n&1) cout<<s++;
        cout<<endl;
    }
}


#include<bits/stdc++.h>
#define ll long long
#define S second
#define F first

using namespace std;

const ll N = 2e6+5, mod = 1e9 + 7, mod1 = mod-1;

int main()
{
    int n, nn;
    scanf("%d", &n);
    nn = n*n;
    int st = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        st = i-1;
        for(int j = 0 ; j < n ; j++)
        {
            cout << j * n + st + 1 <<" " ;
            st++;
            st %= n;
        }cout<<endl;
    }
}


#include<bits/stdc++.h>
#define ll long long
#define S second
#define F first

using namespace std;

const ll N = 2e6+5, mod = 1e9 + 7, mod1 = mod-1;

int main()
{
    int n, e, s;
    cin>>n;
    e = n*n, s = 1;
    for(int i = 1 ; i <= n ; i++)
    {
        for(int j = 1 ; j < n ; j+=2)
        {
            cout<< s++<<" "<<e--<<" ";
        }
        if(n&1) cout<<s++;
        cout<<endl;
    }
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> //Policy Based Data Structure
// using namespace __gnu_pbds;              //Policy Based Data Structure
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; //Policy Based Data Structure
// #define gc              getchar_unlocked
// #define pqb             priority_queue<int>
// #define pqs             priority_queue<int, vi, greater<int> >
// #define mk(arr,n,type)  type *arr = new type[n]
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int             long long
#define endl            '\n'
#define w(t)            int t; cin>>t; while(t--)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x,y)       cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define tr(it,a)        for(auto it = a.begin(); it != a.end(); it++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define PI              3.1415926535897932384626
#define inf             1e18
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());  //Random Shuffler
typedef pair<int, int>   pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
typedef map<int, int>    mii;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
// const int N = 3e5, M = N;
// vi g[N];
//=======================

int i;

void sol()
{
	int n;
	cin >> n;
	int t = (n * n) + 1;
	int a[t];
	fo(i, t)a[i] = 1;
	a[0] = 0;
	for (i = 1; i < n; i++)
	{
		int k = (i * n) ;
		cout << k << " ";
		a[k] = 0;
	}
	int k = (n * n) - 1;
	cout << k << " ";
	a[k] = 0;
	cout << '\n';
	for (i = 1; i < n; i++)
	{
		k = (i * n) - 1;
		cout << k << " ";
		a[k] = 0;
	}
	k = (n * n) ;
	cout << k  << " ";
	a[k] = 0;
	cout << '\n';

	for (i = 1; i <= n - 2; i++)
	{
		int count = 0; int j = 1;
		while (count <= n && j <= n * n)
		{
			if (a[j] == 1)
			{
				cout << j << " ";
				a[j] = 0;
				count++;
			}

			j++;
		}
		cout << '\n';
	}
}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	sol();

	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = (result * base) % mod;
		base = (base * base) % mod;
		exp >>= 1;
	}
	return result;
}

// void ipgraph(int n, int m){
//     int i, u, v;
//     while(m--){
//         cin>>u>>v;
//         g[u-1].pb(v-1);
//         g[v-1].pb(u-1);
//     }
// }
//
// void dfs(int u, int par){
//     for(int v:g[u]){
//         if (v == par) continue;
//         dfs(v, u);
//     }
// }


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> //Policy Based Data Structure
// using namespace __gnu_pbds;              //Policy Based Data Structure
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; //Policy Based Data Structure
// #define gc              getchar_unlocked
// #define pqb             priority_queue<int>
// #define pqs             priority_queue<int, vi, greater<int> >
// #define mk(arr,n,type)  type *arr = new type[n]
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int             long long
#define endl            '\n'
#define w(t)            int t; cin>>t; while(t--)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x,y)       cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define tr(it,a)        for(auto it = a.begin(); it != a.end(); it++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define PI              3.1415926535897932384626
#define inf             1e18
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());  //Random Shuffler
typedef pair<int, int>   pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
typedef map<int, int>    mii;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
// const int N = 3e5, M = N;
// vi g[N];
//=======================

int i;

void sol()
{
	int n, j;
	cin >> n;
	int a[n][n];
	int count = 1;

	for (i = 0; i < n; i++)
	{
		for (int j = 0; j < n; ++j)
		{
			a[j][i] = count;
			count++;
		}

	}
	for (i = 0; i < n; i++)
	{
		for (int j = 0; j < n; ++j)
		{
			cout << a[i][j] << " ";
		}
		cout << '\n';
	}
}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	sol();

	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = (result * base) % mod;
		base = (base * base) % mod;
		exp >>= 1;
	}
	return result;
}

// void ipgraph(int n, int m){
//     int i, u, v;
//     while(m--){
//         cin>>u>>v;
//         g[u-1].pb(v-1);
//         g[v-1].pb(u-1);
//     }
// }
//
// void dfs(int u, int par){
//     for(int v:g[u]){
//         if (v == par) continue;
//         dfs(v, u);
//     }
// }


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> //Policy Based Data Structure
// using namespace __gnu_pbds;              //Policy Based Data Structure
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; //Policy Based Data Structure
// #define gc              getchar_unlocked
// #define pqb             priority_queue<int>
// #define pqs             priority_queue<int, vi, greater<int> >
// #define mk(arr,n,type)  type *arr = new type[n]
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int             long long
#define endl            '\n'
#define w(t)            int t; cin>>t; while(t--)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x,y)       cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define tr(it,a)        for(auto it = a.begin(); it != a.end(); it++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define PI              3.1415926535897932384626
#define inf             1e18
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());  //Random Shuffler
typedef pair<int, int>   pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
typedef map<int, int>    mii;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
// const int N = 3e5, M = N;
// vi g[N];
//=======================

int i;

void sol()
{
	int n, j;
	cin >> n;
	int a[n][n];
	int count = 1;

	for (i = 0; i < n; i++)
	{
		if (i % 2 == 0)
			for (int j = 0; j < n; ++j)
			{
				a[j][i] = count;
				count++;
			}
		else
			for (int j = n - 1; j >= 0; j--)
			{
				a[j][i] = count;
				count++;
			}

	}
	for (i = 0; i < n; i++)
	{
		for (int j = 0; j < n; ++j)
		{
			cout << a[i][j] << " ";
		}
		cout << '\n';
	}
}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	sol();

	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = (result * base) % mod;
		base = (base * base) % mod;
		exp >>= 1;
	}
	return result;
}

// void ipgraph(int n, int m){
//     int i, u, v;
//     while(m--){
//         cin>>u>>v;
//         g[u-1].pb(v-1);
//         g[v-1].pb(u-1);
//     }
// }
//
// void dfs(int u, int par){
//     for(int v:g[u]){
//         if (v == par) continue;
//         dfs(v, u);
//     }
// }


//created by --------> Aslan Nesipbay[ BlackLion ];

#include<bits/stdc++.h>

// instagram.com/aslandoos
// vk.com/noone_knows_me

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef stringstream SS;
typedef pair<ll,ll> pll;

const ll N = 100005;
const ll NN = 105;
const ll MAX = 2e5 + 123;
const ll MOD = 1e9 + 8;

void hajime()
{
    ll n;
    scanf( "%I64d", &n );
    vector< ll > v[ n ];
    for( ll i = 1; i <= n; i ++ )
    {
        ll s = i;
        for( ll j = 1; j <= n; j ++ )
        {
            if( j == 1 )
            {
                cout << s << ' ';
                continue;
            }
            else s += n;
            cout << s << ' ';
        }
        cout << '\n';
    }
}
int main()
{
    /*ll miyagi;
    scanf( "%I64d", &miyagi );
    while( miyagi -- ) */
        hajime();
}


//created by --------> Aslan Nesipbay[ BlackLion ];

#include<bits/stdc++.h>

// instagram.com/aslandoos
// vk.com/noone_knows_me

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef stringstream SS;
typedef pair<ll,ll> pll;

const ll N = 100005;
const ll NN = 105;
const ll MAX = 2e5 + 123;
const ll MOD = 1e9 + 8;

ll n, a[ NN * 3 ][ NN * 3 ];
void dfs( ll q, ll w, ll e ,ll r ){
    a[ q ][ w ] = e;
    if( e == pow( n, 2 ) ) return;
    if( e % n == 0 ){
        r = 1 - r;
        dfs( q, w + 1, e + 1, r);
        return;
    }
    if( r == 0 ) dfs( q + 1, w, e + 1, r );
    else dfs( q - 1, w, e + 1, r );
}
void hajime()
{
    cin >> n;
    dfs( 1, 1, 1, 0 );
    for( ll i = 1; i <= n; i ++ ){
        for( ll j = 1; j <= n; j ++ ){
        cout << a[ i ][ j ] << ' ';
        }
        cout << '\n';
    }
}
int main()
{
    /*ll miyagi;
    scanf( "%I64d", &miyagi );
    while( miyagi -- ) */
        hajime();
}


//created by --------> Aslan Nesipbay[ BlackLion ];

#include<bits/stdc++.h>

// instagram.com/aslandoos
// vk.com/noone_knows_me

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef stringstream SS;
typedef pair<ll,ll> pll;

const ll N = 100005;
const ll NN = 105;
const ll MAX = 2e5 + 123;
const ll MOD = 1e9 + 7;

void hajime()
{
    ll n;
    scanf( "%I64d", &n );
    vector< ll > v[ N ];
    for( ll i = 1; i <= n * n; i ++ )
    {
        if( i % n == 0 ) v[ i / n - 1 ].push_back( i );
        else v[ i / n ].push_back( i );
    }
    for( ll i = 0; i < n; i ++ )
    {
        if( i % 2 ) reverse( v[ i ].begin(), v[ i ].end() );
    }
    for( ll i = 0; i < n; i ++ )
    {
        for( ll j = 0; j < n; j ++ ) cout << v[ j ][ i ] << ' ';
        cout << '\n';
    }
}

int main()
{
    /*ll miyagi;
    scanf( "%I64d", &miyagi );
    while( miyagi -- ) */
        hajime();
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int magicSquare[n][n];
    memset(magicSquare, 0, sizeof(magicSquare));
    int i = n/2;
    int j = n-1;
    for (int num = 1; num <= n*n; )
    {
        if (i == -1 && j == n)
        {
            j = n-2;
            i = 0;
        }
        else
        {
            if (j == n)
                j = 0;
            if (i < 0)
                i = n - 1;
        }
        if (magicSquare[i][j])
        {
            j -= 2;
            i++;
            continue;
        }
        else
            magicSquare[i][j] = num++;

        j++; i--;
    }
  	for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
            cout<<magicSquare[i][j]<<" ";
        cout<<endl;
    }
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int k=1;
	int a[n][n],flag=0;
	for(int i=0;i<n;i++)
	{
		if(flag==0)
		{
			for(int j=0;j<n;j++)
			{
				a[j][i]=k;
				k++;
			}
			flag=1;
		}
		else if(flag==1)
		{
			for(int j=n-1;j>=0;j--)
			{
				a[j][i]=k;
				k++;
			}
			flag=0;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
void doublyEven( int n )
{
    int arr[n][n], i, j;
    for ( i = 0; i < n; i++)
        for ( j = 0; j < n; j++)
            arr[i][j] = (n*i) + j + 1;
    for ( i = 0; i < n/4; i++)
        for ( j = 0; j < n/4; j++)
            arr[i][j] = (n*n + 1) - arr[i][j];
    for ( i = 0; i < n/4; i++)
        for ( j = 3 * (n/4); j < n; j++)
            arr[i][j] = (n*n + 1) - arr[i][j];
    for ( i = 3 * n/4; i < n; i++)
        for ( j = 0; j < n/4; j++)
            arr[i][j] = (n*n+1) - arr[i][j];
    for ( i = 3 * n/4; i < n; i++)
        for ( j = 3 * n/4; j < n; j++)
            arr[i][j] = (n*n + 1) - arr[i][j];
    for ( i = n/4; i < 3 * n/4; i++)
        for ( j = n/4; j < 3 * n/4; j++)
            arr[i][j] = (n*n + 1) - arr[i][j];
    for (i = 0; i < n; i++)
    {
        for ( j = 0; j < n; j++)
            cout << arr[i][j] << " ";
        cout << "\n";
    }
}
void sex(int n)
{
	int magicSquare[n][n];
    memset(magicSquare, 0, sizeof(magicSquare));
    int i = n/2;
    int j = n-1;
    for (int num = 1; num <= n*n; )
    {
        if (i == -1 && j == n)
        {
            j = n-2;
            i = 0;
        }
        else
        {
            if (j == n)
                j = 0;
            if (i < 0)
                i = n - 1;
        }
        if (magicSquare[i][j])
        {
            j -= 2;
            i++;
            continue;
        }
        else
            magicSquare[i][j] = num++;

        j++; i--;
    }
  	for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
            cout<<magicSquare[i][j]<<" ";
        cout<<endl;
    }
}
int main()
{
	int n;
	cin>>n;
	if(n%2==0)
		doublyEven(n);
	else
		sex(n);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};//king move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin>>n;

  for(int i=1;i<=n;i++)
  {
      for(int j=0;j<n;j++)
      {
          if(j%2==0)
          {
              cout<<n*j+i<<" ";
          }
          else
          {
              cout<<(n*(j+1)-i+1)<<" ";
          }
      }
      cout<<"\n";
  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};//king move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin>>n;

  vector<int>v;

  for(int i=1;i<=(n*n);i++)
  {
      v.push_back(i);
  }

   for(int i=n;i<(n*n);i+=2)
   {
          swap(v[i],v[i+1]);
   }

  for(int i=0;i<n;i++)
  {
     for(int j=i;j<(n*n);j+=n)
     {
         cout<<v[j]<<" ";
     }
     cout<<"\n";
  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};//king move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin>>n;

  vector<int>v;

  for(int i=1;i<=(n*n);i++)
  {
      v.push_back(i);
  }

   for(int i=0;i<(n*n);i++)
  {
      if(i%2==0 && i!=0 && i<((n*n)-1))
      {
          swap(v[i],v[i+1]);
      }
  }
  int k=0;
  for(int i=1;i<=n;i++)
  {
      int j;
      for(j=k;j<n*i;j++)
      {
          cout<<v[j]<<" ";

      }
      k=j;
      cout<<"\n";
  }

  return 0;
}


/* Author : the_compiler */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int siz =1e5+7;
const int siz2=2e5+7;

int n;
vector<int>v1;
vector<int>v2;
vector<int>v3;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    int i=1;
    bool Flag=true;
    while(n--)
    {
        if(Flag)
        {
            v1.push_back(i++);
            v2.push_back(i++);
            v3.push_back(i++);
        }
        else
        {
            v3.push_back(i++);
            v2.push_back(i++);
            v1.push_back(i++);
        }
        Flag=!Flag;
    }
    for(auto v : v1)cout<<v<<" ";cout<<endl;
    for(auto v : v2)cout<<v<<" ";cout<<endl;
    for(auto v : v3)cout<<v<<" ";cout<<endl;
   return 0;
}


/* Author : the_compiler */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int siz =1e5+7;
const int siz2=2e5+7;

int n;
int a[333][333];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;

    int c=1;
    for(int i=0;i<n;++i)
    {
        if(i & 1)
        {
            for(int j=0;j<n;++j)
                a[j][i]=c++;
        }
        else{
            for(int j=n-1;j>=0;--j)
                a[j][i]=c++;
        }
    }
    for(int j=0;j<n;++j)
    {
        for(int k=0;k<n;++k)
        {
            cout<<a[j][k]<<" ";
        }
        cout<<endl;
    }
   return 0;
}


/* Author : the_compiler */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int siz =1e5+7;
const int siz2=2e5+7;

int n;
vector<int>v1;
vector<int>v2;
vector<int>v3;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    int i=1;
    bool Flag=true;
    while(n--)
    {
        if(Flag)
        {
            v1.push_back(i++);
            v2.push_back(i++);
            v3.push_back(i++);
        }
        else
        {
            v3.push_back(i++);
            v2.push_back(i++);
            v1.push_back(i++);
        }
        Flag!=Flag;
    }
    for(auto v : v1)cout<<v<<" ";cout<<endl;
    for(auto v : v2)cout<<v<<" ";cout<<endl;
    for(auto v : v3)cout<<v<<" ";cout<<endl;
   return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define pii pair<int,int>
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;
const int mod = 1000000000+7;

ll powmod(ll a, ll b)
{
	ll ans = 1;
	for(ll i =1; i<=b; i<<=1)
	{
		if(i&b)ans = ans*a%mod;
		a = a*a%mod;
	}
	return ans;
}

int main()
{

	int n;
	cin >> n;
	int l = 1, r = n*n;
	for(int ii = 1; ii<=n; ii++)
	{
		for(int i = 1; i<=n/2; i++)
			cout << l ++ << " ";
		for(int i = n/2+1; i<=n; i++)
			cout << r-- << " ";
		cout <<endl;
	}

	return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define pii pair<int,int>
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;
const int mod = 1000000000+7;

ll powmod(ll a, ll b)
{
	ll ans = 1;
	for(ll i =1; i<=b; i<<=1)
	{
		if(i&b)ans = ans*a%mod;
		a = a*a%mod;
	}
	return ans;
}

int main()
{

	int n;
	cin >> n;
	for(int ii = 1; ii<=n; ii++)
	{
		for(int j = 1; j<=n*n; j+=n)
			cout << (((j/n)&1) ? (j + ii -1 ) : (j + n - ii)) << " ";
		cout << endl;
	}

	return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define pii pair<int,int>
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;
const int mod = 1000000000+7;

ll powmod(ll a, ll b)
{
	ll ans = 1;
	for(ll i =1; i<=b; i<<=1)
	{
		if(i&b)ans = ans*a%mod;
		a = a*a%mod;
	}
	return ans;
}

int main()
{

	int n;
	cin >> n;
	for(int ii = 1; ii<=n; ii++)
	{
		for(int j = 1; j<=n*n; j+=n)
			cout << ((j&1) ? (j + ii -1 ) : (j + n - ii)) << " ";
		cout << endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int a[310][310];
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n;i++)
	for (int j = 1; j <= n; j++){
		if (i % 2 != 0)
			a[j][i] = (i / 2*2) * n + j;
		else a[j][i] = i  * n - j + 1;
	}
	for (int i = 1; i <= n;i++,cout<<endl)
	for (int j = 1; j <= n; j++){
		cout << a[i][j] << " ";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int a[310][310];
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n;i++)
	for (int j = 1; j <= n; j++){
		if (i % 2 != 0)
			a[j][i] = (i / 2*2) * 3 + j;
		else a[j][i] = (i / 2 + 1) * 3 - j + 1;
	}
	for (int i = 1; i <= n;i++,cout<<endl)
	for (int j = 1; j <= n; j++){
		cout << a[i][j] << " ";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int a[310][310];
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n;i++)
	for (int j = 1; j <= n; j++){
		if (i % 2 != 0)
			a[j][i] = (i / 2*2) * n + j;
		else a[j][i] = (i / 2 + 1) * n - j + 1;
	}
	for (int i = 1; i <= n;i++,cout<<endl)
	for (int j = 1; j <= n; j++){
		cout << a[i][j] << " ";
	}
	return 0;
}


/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂

                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ

 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define V vector<ll>
#define P pair<<ll,ll>
#define VP vector<pair<ll,ll>>
#define f first
#define s second
#define N 1000000
#define pb push_back
#define mp make_pair
#define test int __t; scanf("%d",&__t) ; while(__t--)
vector<ll>v;
ll mx=-1e18+10;
ll mn=1e18+10;
ll l,m,n,sum,ans,a,b,c,t,i,j,k,q,r;
ll cnt,cnt1,cnt2,cnt3;
string str,str1,str2;
void mahakal(){
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr);
    #endif

}

int power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main(){
    mahakal();fast;
    cin>>n;
    k=1;
    int arr[n+1][n+1];
    for(i=0;i<n;i++){
    	for(j=0;j<n;j++){
    		arr[i][j]=k;
    		k++;
    	}
    }
    for(i=0;i<n;i++){
    	for(j=0;j<n;j++){
    		cout<<arr[j][i]<<" ";
    	}
    	cout<<endl;
    }
    return 0;
}


/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂

                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ

 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define V vector<ll>
#define P pair<<ll,ll>
#define VP vector<pair<ll,ll>>
#define f first
#define s second
#define N 1000000
#define pb push_back
#define mp make_pair
#define test int __t; scanf("%d",&__t) ; while(__t--)
vector<ll>v;
ll mx=-1e18+10;
ll mn=1e18+10;
ll l,m,n,sum,ans,a,b,c,t,i,j,k,q,r;
ll cnt,cnt1,cnt2,cnt3;
string str,str1,str2;
void mahakal(){
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr);
    #endif

}

int main(){
    mahakal();fast;

    cin>>n;
    int arr[n][n];
    int ps=1;
    k=1;
    for(i=0;i<n;i++){
    	if(ps==1){
    		for(j=0;j<n;j++){
    			arr[j][i]=k;
    			k++;
    		}
    		ps=ps^1;
    	}
    	else{
    		for(j=n-1;j>=0;j--){
    			arr[j][i]=k;
    			k++;
    		}
    		ps=ps^1;
    	}
    }
    for(i=0;i<n;i++){
    	for(j=0;j<n;j++){
    		cout<<arr[i][j]<<" ";
    	}
    	cout<<endl;
    }

    return 0;
}


/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂

                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ

 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define V vector<ll>
#define P pair<<ll,ll>
#define VP vector<pair<ll,ll>>
#define f first
#define s second
#define N 1000000
#define pb push_back
#define mp make_pair
#define test int __t; scanf("%d",&__t) ; while(__t--)
vector<ll>v;
ll mx=-1e18+10;
ll mn=1e18+10;
ll l,m,n,sum,ans,a,b,c,t,i,j,k,q,r;
ll cnt,cnt1,cnt2,cnt3;
string str,str1,str2;
void mahakal(){
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr);
    #endif

}

int power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main(){
    mahakal();fast;
    cin>>n;
    k=n*n;
    int arr[n+1][n+1];
    for(i=0;i<n;i++){
    	for(j=0;j<n;j++){
    		arr[i][j]=k;
    		k--;
    	}
    }
    for(i=0;i<n;i++){
    	for(j=0;j<n;j++){
    		cout<<arr[j][i]<<" ";
    	}
    	cout<<endl;
    }
    return 0;
}


/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂

                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ

 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define V vector<ll>
#define P pair<<ll,ll>
#define VP vector<pair<ll,ll>>
#define f first
#define s second
#define N 1000000
#define pb push_back
#define mp make_pair
#define test int __t; scanf("%d",&__t) ; while(__t--)
vector<ll>v;
ll mx=-1e18+10;
ll mn=1e18+10;
ll l,m,n,sum,ans,a,b,c,t,i,j,k,q,r;
ll cnt,cnt1,cnt2,cnt3;
string str,str1,str2;
void mahakal(){
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr);
    #endif

}

int power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main(){
    mahakal();fast;
    cin>>n;
    k=1;
    int arr[n+1][n+1];
    for(i=0;i<n;i++){
    	for(j=0;j<n;j++){
    		arr[i][j]=k;
    		k++;
    	}
    }
    int ps=1;
    for(i=0;i<n;i++){
    	if(ps==1){
    	for(j=0;j<n;j++){
    		cout<<arr[j][i]<<" ";
    	}
    	ps=ps^1;
    }
    else{
    	for(j=n-1;j>=0;j--){
    		cout<<arr[j][i]<<" ";
    	}
		ps=ps^1;
	}

    	cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>//
#define  cin(x) scanf("%d",&x)
#define cinc(x) scanf("%c",&x);while(!(ch>='0'&&ch<='9'||ch>='a'&&ch<='z'||ch>='A'&&ch<='Z'||ch=='.'))scanf("%c",&x);
#define kt int T;scanf("%lld",&T);while(T--)
#define mem0(x) memset(x,0,sizeof(x));
#define mem_1(x) memset(x,-1,sizeof(x));
#define INT2 0x7ffffff
#define  ll long long
//#define int ll
using namespace std;
int d[1000][1000];

int main()
{
    int n;
    cin>>n;
    int st=0;
    int xb=1;
    for(int i=0;i<n;i++){
        int n1=n;
        int chufa=st;
        while(n1--){
            d[chufa][i]=xb++;
            chufa=(chufa+1)%n;
        }
        st=st+1;

    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<d[i][j]<<' ';

        }
        cout<<endl;
    }

}


#include<bits/stdc++.h>//
#define  cin(x) scanf("%d",&x)
#define cinc(x) scanf("%c",&x);while(!(ch>='0'&&ch<='9'||ch>='a'&&ch<='z'||ch>='A'&&ch<='Z'||ch=='.'))scanf("%c",&x);
#define kt int T;scanf("%lld",&T);while(T--)
#define mem0(x) memset(x,0,sizeof(x));
#define mem_1(x) memset(x,-1,sizeof(x));
#define INT2 0x7ffffff
#define  ll long long
//#define int ll
using namespace std;
int d[1000][1000];

int main()
{
    int n;
    cin>>n;

    int xb=1;

    for(int j=1; j<=(n%2==1?n/2+1:n/2); j++)
    {
        for(int i=1; i<=n-1; i++)
        {
            d[i][j]=xb++;
        }
        j=j+1;
        if(j>(n%2==1?n/2+1:n/2))
            break;
        for(int i=n-1; i>=1; i--)
        {
            d[i][j]=xb++;
        }

    }
    xb=n*n;
    for(int j=n; j>=n/2; j--)
    {
        if(d[1][j]!=0)
            break;

        for(int i=1; i<=n-1; i++)
        {
            d[i][j]=xb--;
        }
        j=j-1;
        if(j<=n/2||d[1][j]!=0)
            break;
        for(int i=n-1; i>=1; i--)
        {
            d[i][j]=xb--;
        }

    }
    for(int i=1; i<=n; i++)
    {
        d[n][i]=xb--;
    }

    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            cout<<d[i][j]<<' ';

        }
        cout<<endl;
    }

}


#include<bits/stdc++.h>
#define  cin(x) scanf("%d",&x)
#define cinc(x) scanf("%c",&x);while(!(ch>='0'&&ch<='9'||ch>='a'&&ch<='z'||ch>='A'&&ch<='Z'||ch=='.'))scanf("%c",&x);
#define kt int T;scanf("%lld",&T);while(T--)
#define mem0(x) memset(x,0,sizeof(x));
#define mem_1(x) memset(x,-1,sizeof(x));
#define INT2 0x7ffffff
#define  ll long long
//#define int ll
using namespace std;
int d[1000][1000];

int main()
{
    int n;
    cin>>n;
    if(n%2==1)
    {
        int st=0;
        int xb=1;
        for(int i=0; i<n; i++)
        {
            int n1=n;
            int chufa=st;
            while(n1--)
            {
                d[chufa][i]=xb++;
                chufa=(chufa+1)%n;
            }
            st=st+1;

        }
    }
    else
    {
        int xb=1;

        for(int j=1; j<=n/2; j++)
        {
            for(int i=1; i<=n-1; i++)
            {
                d[i][j]=xb++;
            }
            j=j+1;
            if(j>n/2)
                break;
            for(int i=n-1; i>=1; i--)
            {
                d[i][j]=xb++;
            }

        }
        xb=n*n;
        for(int j=n; j>n/2; j--)
        {
            for(int i=1; i<=n-1; i++)
            {
                d[i][j]=xb--;
            }
            j=j-1;
            if(j<=n/2)
                break;
            for(int i=n-1; i>=1; i--)
            {
                d[i][j]=xb--;
            }

        }
        for(int i=1; i<=n; i++)
        {
            d[n][i]=xb--;
        }

    }

    if(n%2==1)
    {
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                cout<<d[i][j]<<' ';

            }
            cout<<endl;
        }
    }else{
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=n; j++)
            {
                cout<<d[i][j]<<' ';

            }
            cout<<endl;
        }
    }

}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
    return x*f;
}
const int N=507;
int n,A[N][N],L[N],R[N];
int main()
{
    n=read(); int tot=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++) A[i][j]=++tot;
        L[i]=1,R[i]=n;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if((i^j)&1) printf("%d ",A[j][L[j]++]);
            else printf("%d ",A[j][R[j]--]);
        }
        puts("");
    }
    return 0;
}


#include<bits/stdc++.h>//
#define  cin(x) scanf("%d",&x)
#define cinc(x) scanf("%c",&x);while(!(ch>='0'&&ch<='9'||ch>='a'&&ch<='z'||ch>='A'&&ch<='Z'||ch=='.'))scanf("%c",&x);
#define kt int T;scanf("%lld",&T);while(T--)
#define mem0(x) memset(x,0,sizeof(x));
#define mem_1(x) memset(x,-1,sizeof(x));
#define INT2 0x7ffffff
#define  ll long long
//#define int ll
using namespace std;
int d[1000][1000];

int main()
{
    int n;
    cin>>n;
    if(n%2==1)
    {
        int st=0;
        int xb=1;
        for(int i=0; i<n; i++)
        {
            int n1=n;
            int chufa=st;
            while(n1--)
            {
                d[chufa][i]=xb++;
                chufa=(chufa+1)%n;
            }
            st=st+1;

        }
    }
    else
    {
        int xb=1;

        for(int j=1; j<=n/2; j++)
        {
            for(int i=1; i<=n-1; i++)
            {
                d[i][j]=xb++;
            }
            j=j+1;
            if(j>n/2)
                break;
            for(int i=n-1; i>=1; i--)
            {
                d[i][j]=xb++;
            }

        }
        xb=n*n;
        for(int j=n; j>n/2; j--)
        {
            for(int i=1; i<=n-1; i++)
            {
                d[i][j]=xb--;
            }
            j=j-1;
            if(j<=n/2)
                break;
            for(int i=n-1; i>=1; i--)
            {
                d[i][j]=xb--;
            }

        }
        for(int i=1; i<=n; i++)
        {
            d[n][i]=xb--;
        }

    }

    if(n%2==1)
    {
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                cout<<d[i][j]<<' ';

            }
            cout<<endl;
        }
    }else{
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=n; j++)
            {
                cout<<d[i][j]<<' ';

            }
            cout<<endl;
        }
    }

}


#include<bits/stdc++.h>//
#define  cin(x) scanf("%d",&x)
#define cinc(x) scanf("%c",&x);while(!(ch>='0'&&ch<='9'||ch>='a'&&ch<='z'||ch>='A'&&ch<='Z'||ch=='.'))scanf("%c",&x);
#define kt int T;scanf("%lld",&T);while(T--)
#define mem0(x) memset(x,0,sizeof(x));
#define mem_1(x) memset(x,-1,sizeof(x));
#define INT2 0x7ffffff
#define  ll long long
//#define int ll
using namespace std;
int d[1000][1000];

int main()
{
    int n;
    cin>>n;

    int xb=1;

    for(int j=1; j<=n/2; j++)
    {
        for(int i=1; i<=n-1; i++)
        {
            d[i][j]=xb++;
        }
        j=j+1;
        if(j>n/2)
            break;
        for(int i=n-1; i>=1; i--)
        {
            d[i][j]=xb++;
        }

    }
    xb=n*n;
    for(int j=n; j>n/2; j--)
    {
        if(d[1][j]!=0)
            break;

        for(int i=1; i<=n-1; i++)
        {
            d[i][j]=xb--;
        }
        j=j-1;
        if(j<=n/2)
            break;
        for(int i=n-1; i>=1; i--)
        {
            d[i][j]=xb--;
        }

    }
    for(int i=1; i<=n; i++)
    {
        d[n][i]=xb--;
    }

    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            cout<<d[i][j]<<' ';

        }
        cout<<endl;
    }

}


#include<bits/stdc++.h>
#define  cin(x) scanf("%d",&x)
#define cinc(x) scanf("%c",&x);while(!(ch>='0'&&ch<='9'||ch>='a'&&ch<='z'||ch>='A'&&ch<='Z'||ch=='.'))scanf("%c",&x);
#define kt int T;scanf("%lld",&T);while(T--)
#define mem0(x) memset(x,0,sizeof(x));
#define mem_1(x) memset(x,-1,sizeof(x));
#define INT2 0x7ffffff
#define  ll long long
//#define int ll
using namespace std;
int d[1000][1000];

int main()
{
    int n;
    cin>>n;
    if(n%2==1)
    {
        int st=0;
        int xb=1;
        for(int i=0; i<n; i++)
        {
            int n1=n;
            int chufa=st;
            while(n1)
            {
                d[chufa][i]=xb++;
                chufa=(chufa+1)%n;
            }
            st=st+1;

        }
    }
    else
    {
        int xb=1;

        for(int j=1; j<=n/2; j++)
        {
            for(int i=1; i<=n-1; i++)
            {
                d[i][j]=xb++;
            }
            j=j+1;
            if(j>n/2)
                break;
            for(int i=n-1; i>=1; i--)
            {
                d[i][j]=xb++;
            }

        }
        xb=n*n;
        for(int j=n; j>n/2; j--)
        {
            for(int i=1; i<=n-1; i++)
            {
                d[i][j]=xb--;
            }
            j=j-1;
            if(j<=n/2)
                break;
            for(int i=n-1; i>=1; i--)
            {
                d[i][j]=xb--;
            }

        }
        for(int i=1; i<=n; i++)
        {
            d[n][i]=xb--;
        }

    }

    if(n%2==1)
    {
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                cout<<d[i][j]<<' ';

            }
            cout<<endl;
        }
    }else{
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=n; j++)
            {
                cout<<d[i][j]<<' ';

            }
            cout<<endl;
        }
    }

}


// Problem : C. Labs
// Contest : Codeforces - Codeforces Round #593 (Div. 2)
// URL : https://codeforces.com/contest/1236/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double
#define no_of_digits(n) floor(log10(n)) + 1
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define see(x) cout << #x << "=" << x << endl;
#define see2(x, y) cout << #x << "=" << x << "\t" << #y << "=" << y << endl;
#define see3(x, y, z) cout << #x << "=" << x << "\t" << #y << "=" << y << "\t" << #z << "=" << z << endl;
#define INF 1e9+5
#define LL_MAX 1e18+5

using namespace std;

const ld PI = acos((ld)-1);

ll modmult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll modmultbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=modmultbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll modadd(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll modsub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = modmult(r,n,p); n = modmult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

int isPowerof2(ll x) { return (x && !(x & (x-1))); }

ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; }

bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }

bool boundary(ll i,ll j,ll n, ll m){return (i>=0 && i<n && j>=0 &&  j<m);} //matrix boundary checking

ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
ll lcm(ll a, ll b){return a/__gcd(a, b)*b;}

string alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};

// cout << fixed for removing e notation

bool comp2(const pair<int, int>&a, const pair<int, int>&b)
{
    if(a.second < b.second)
        return true;
    else if(a.second == b.second)
    {
        if(a.fi > b.fi) return true;
        else return false;
    }
    else return false;
}

bool prime[10000005];
void SieveOfEratosthenes(int n)
{
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
    }
}

int main()
{
	int n;
	cin >> n;

	int ans[n][n];
	int x = 0, y = 0;
	bool right = true;

	for(int i=1;i<=n*n;i++)
	{
		ans[x][y] = i;
		// y++;
		if(right)
		{
			y++;
		}
		else
		{
			y--;
		}

		if(y == -1)
		{
			right = true;
			x++;
			y = 0;
		}
		else if(y == n)
		{
			right = false;
			x++;
			y = n-1;
		}
	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++) cout << ans[i][j] << " ";
		cout << "\n";
	}
}


// Problem : C. Labs
// Contest : Codeforces - Codeforces Round #593 (Div. 2)
// URL : https://codeforces.com/contest/1236/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double
#define no_of_digits(n) floor(log10(n)) + 1
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define see(x) cout << #x << "=" << x << endl;
#define see2(x, y) cout << #x << "=" << x << "\t" << #y << "=" << y << endl;
#define see3(x, y, z) cout << #x << "=" << x << "\t" << #y << "=" << y << "\t" << #z << "=" << z << endl;
#define INF 1e9+5
#define LL_MAX 1e18+5

using namespace std;

const ld PI = acos((ld)-1);

ll modmult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll modmultbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=modmultbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll modadd(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll modsub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = modmult(r,n,p); n = modmult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

int isPowerof2(ll x) { return (x && !(x & (x-1))); }

ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; }

bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }

bool boundary(ll i,ll j,ll n, ll m){return (i>=0 && i<n && j>=0 &&  j<m);} //matrix boundary checking

ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
ll lcm(ll a, ll b){return a/__gcd(a, b)*b;}

string alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};

// cout << fixed for removing e notation

bool comp2(const pair<int, int>&a, const pair<int, int>&b)
{
    if(a.second < b.second)
        return true;
    else if(a.second == b.second)
    {
        if(a.fi > b.fi) return true;
        else return false;
    }
    else return false;
}

bool prime[10000005];
void SieveOfEratosthenes(int n)
{
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
    }
}

int main()
{
	int n;
	cin >> n;

	int ans[n][n];
	int x = 0, y = 0;
	bool right = true;

	for(int i=1;i<=n*n;i++)
	{
		ans[x][y] = i;
		// y++;
		if(right)
		{
			y++;
		}
		else
		{
			y--;
		}

		if(y == -1)
		{
			right = true;
			x++;
			y = 0;
		}
		else if(y == n)
		{
			right = false;
			x++;
			y = n-1;
		}
	}

	for(int j=0;j<n;j++)
	{
		for(int i=0;i<n;i++) cout << ans[i][j] << " ";
		cout << "\n";
	}
}


// Problem : C. Labs
// Contest : Codeforces - Codeforces Round #593 (Div. 2)
// URL : https://codeforces.com/contest/1236/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double
#define no_of_digits(n) floor(log10(n)) + 1
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define see(x) cout << #x << "=" << x << endl;
#define see2(x, y) cout << #x << "=" << x << "\t" << #y << "=" << y << endl;
#define see3(x, y, z) cout << #x << "=" << x << "\t" << #y << "=" << y << "\t" << #z << "=" << z << endl;
#define INF 1e9+5
#define LL_MAX 1e18+5

using namespace std;

const ld PI = acos((ld)-1);

ll modmult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll modmultbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=modmultbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll modadd(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll modsub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = modmult(r,n,p); n = modmult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

int isPowerof2(ll x) { return (x && !(x & (x-1))); }

ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; }

bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }

bool boundary(ll i,ll j,ll n, ll m){return (i>=0 && i<n && j>=0 &&  j<m);} //matrix boundary checking

ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
ll lcm(ll a, ll b){return a/__gcd(a, b)*b;}

string alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};

// cout << fixed for removing e notation

bool comp2(const pair<int, int>&a, const pair<int, int>&b)
{
    if(a.second < b.second)
        return true;
    else if(a.second == b.second)
    {
        if(a.fi > b.fi) return true;
        else return false;
    }
    else return false;
}

bool prime[10000005];
void SieveOfEratosthenes(int n)
{
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
    }
}

int main()
{
	int n;
	cin >> n;

	int k = 1;

	vector<int>adj[n];
	int p = 0;
	int by = 1;

	for(int i=1;i<=n*n;)
	{
		for(int j=0;j<n;j++)
		{
			adj[p].pb(i);
			p++;
			if(p == n) p = 0;
			i++;
		}

		p++;
	}

	for(int i=0;i<n;i++)
	{
		for(auto x: adj[i]) cout << x << " ";
		cout << "\n";
	}
}


#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sd second
#define fst first
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define maxn 100010
#define inf 0x3f3f3f3f
map<int,int>mfre;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    LL x=1,y,k=0;
    cin>>n;

    int a[n][n];
    for(int i=0;i<n;i++)
    {
        if(i%2)
        {
            for(int j=n-1;j>=0;j--)
            {
                a[j][i]=x++;
            }

        }
        else
        {
            for(int j=0;j<n;j++)
            {
                a[j][i]=x++;
            }
        }

    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<a[i][j]<<" ";
        }cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sd second
#define fst first
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define maxn 100010
#define inf 0x3f3f3f3f
map<int,int>mfre;
int fre[26];

LL dp[200005];
int ans[200005];
char g[50][50];
bool vs[52][52];
int n,m,cycle;
void dfs(int i,int j,int pi,int pj,char c)
{
    if(i<0||i>=n||j<0||j>=m)
        return;

    if(c!=g[i][j])
        return;

    if(vs[i][j])
    {
        cycle=1;
        return ;
    }

    vs[i][j]=1;

    if( (i+1)!=pi || j!=pj )
    {
        dfs(i+1,j,i,j,c);
    }
    if( (i-1) != pi || (j)!=pj)
    {
        dfs(i-1,j,i,j,c);
    }

    if( i!=pi || (j-1)!=pj )
    {
        dfs(i,j-1,i,j,c);
    }
    if( i!=pi || (j+1)!=pj  )
    {
        dfs(i,j+1,i,j,c);
    }
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    LL x=1,y,k=0;
    cin>>n;

    int a[n][n];
    for(int i=0;i<n;i++)
    {
        if(i%2)
        {
            for(int j=n-1;j>=0;j--)
            {
                a[j][i]=x++;
            }

        }
        else
        {
            for(int j=0;j<n;j++)
            {
                a[j][i]=x++;
            }
        }

    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<a[i][j]<<" ";
        }cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sd second
#define fst first
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define maxn 100010
#define inf 0x3f3f3f3f
map<int,int>mfre;
int fre[26];

LL dp[200005];
int ans[200005];
char g[50][50];
bool vs[52][52];
int n,m,cycle;
void dfs(int i,int j,int pi,int pj,char c)
{
    if(i<0||i>=n||j<0||j>=m)
        return;

    if(c!=g[i][j])
        return;

    if(vs[i][j])
    {
        cycle=1;
        return ;
    }

    vs[i][j]=1;

    if( (i+1)!=pi || j!=pj )
    {
        dfs(i+1,j,i,j,c);
    }
    if( (i-1) != pi || (j)!=pj)
    {
        dfs(i-1,j,i,j,c);
    }

    if( i!=pi || (j-1)!=pj )
    {
        dfs(i,j-1,i,j,c);
    }
    if( i!=pi || (j+1)!=pj  )
    {
        dfs(i,j+1,i,j,c);
    }
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    LL x=1,y,k=0;
    cin>>n;

    int a[n][n];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
    {
        a[i][j]=x++;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<a[j][i]<<" ";
        }cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef double D;
typedef vector<ll> VL;
typedef set<ll> SL;
ll M= 1e9+7;

void solve()
{
	ll n;
	cin>>n;
	vector<ll> v(n*n, 0);
	for(int i=0;i<n*n;i++)v[i]=i+1;
	//if(n==2)
	//{
		//cout<<"1 4\n";
		//cout<<"2 3";
		//return;
	//}
	reverse(v.B, v.B+n);
	//reverse(v.B+ n*n-n, v.E);
	for(int i=0;i<n;i++)
	{
		for(int j=i;j<n*n;j+=n)
		{
			cout<<v[j]<<" ";
		}
		cout<<endl;
	}

}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int t=1;
    //cin>>t;
    while(t--)
    {
	    solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef double D;
typedef vector<ll> VL;
typedef set<ll> SL;
ll M= 1e9+7;

void solve()
{
	ll n;
	cin>>n;
	vector<ll> v(n*n, 0);
	for(int i=0;i<n*n;i++)v[i]=i+1;
	reverse(v.B, v.B+n);
	reverse(v.B+ n*n-n, v.E);
	for(int i=0;i<n;i++)
	{
		for(int j=i;j<n*n;j+=n)
		{
			cout<<v[j]<<" ";
		}
		cout<<endl;
	}

}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int t=1;
    //cin>>t;
    while(t--)
    {
	    solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef double D;
typedef vector<ll> VL;
typedef set<ll> SL;
ll M= 1e9+7;

void solve()
{
	ll n;
	cin>>n;
	vector<ll> v(n*n, 0);
	for(int i=0;i<n*n;i++)v[i]=i+1;
	//if(n==2)
	//{
		//cout<<"1 4\n";
		//cout<<"2 3";
		//return;
	//}
	for(int i=n;i<=n*n;i+=2*n)reverse(v.B+i-n, v.B+i);

	for(int i=0;i<n;i++)
	{
		for(int j=i;j<n*n;j+=n)
		{
			cout<<v[j]<<" ";
		}
		cout<<endl;
	}

}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int t=1;
    //cin>>t;
    while(t--)
    {
	    solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef double D;
typedef vector<ll> VL;
typedef set<ll> SL;
ll M= 1e9+7;

void solve()
{
	ll n;
	cin>>n;
	vector<ll> v(n*n, 0);
	for(int i=0;i<n*n;i++)v[i]=i+1;
	if(n==2)
	{
		cout<<"1 4\n";
		cout<<"2 3";
		return;
	}
	reverse(v.B, v.B+n);
	reverse(v.B+ n*n-n, v.E);
	for(int i=0;i<n;i++)
	{
		for(int j=i;j<n*n;j+=n)
		{
			cout<<v[j]<<" ";
		}
		cout<<endl;
	}

}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int t=1;
    //cin>>t;
    while(t--)
    {
	    solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef double D;
typedef vector<ll> VL;
typedef set<ll> SL;
ll M= 1e9+7;

void solve()
{
	ll n;
	cin>>n;
	vector<ll> v(n*n, 0);
	for(int i=0;i<n*n;i++)v[i]=i+1;
	//if(n==2)
	//{
		//cout<<"1 4\n";
		//cout<<"2 3";
		//return;
	//}
	reverse(v.B, v.B+n);
	if(n%2!=0)
	reverse(v.B+ n*n-n, v.E);
	for(int i=0;i<n;i++)
	{
		for(int j=i;j<n*n;j+=n)
		{
			cout<<v[j]<<" ";
		}
		cout<<endl;
	}

}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    int t=1;
    //cin>>t;
    while(t--)
    {
	    solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long int
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define test long long int t; cin>>t; while(t-->0)
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(long long int i=0;i<n;i++)
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b)
 {
    return (a*b)/__gcd(a, b);
 }
 ll power(ll x, unsigned ll y)
 {
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
 }
 bool isPrime(ll num)
 {
    bool flag=true;
    for(ll i =2;i<=num/2;i++)
    {
       if(num%i==0)
       {
          flag=false;
          break;
       }
    }
    return flag;
}
bool isPalin(ll num)
{
    bool flag=false;
    ll digit,rev=0,n=num;
    do
     {
         digit = num % 10;
         rev = (rev * 10) + digit;
         num = num / 10;
     } while (num != 0);
     if(rev==n)
     flag=true;
     return flag;
}
ll sumofdigits(ll n)
{
    ll c=0;
    while(n>0)
    {
        c++;
        n/=10;
    }
    return c;
}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.first > b.first);
}
#define ull unsigned long long int
    ull factorial(int n)
    {
        ull ans;
        if(n<INT_MAX)
        {
        ans=1;
        for(int i=2;i<=n;i++)
         ans=(ans*i)%mod;
         return ans;
        }
    }
int main()
{
    fIO
        ll n;
        cin>>n;
        ll d=1;
        for(ll i=1;i<=n;i++)
        {
            cout<<d<<" ";
            for(ll j=2;j<=n;j++)
            {
                d=d+n;
                cout<<d<<" ";
            }
            d=i;
            cout<<endl;
            d++;
        }
	return 0;
}