// #pragma GCC optimize("O3")
// #pragma GCC target("sse4")

#include <bits/stdc++.h>

using namespace std;

#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define __FOR3(i, a, n, inc) for(int i = (a); (inc) > 0 ? i < (n) : i >= (n); i += (inc))
#define __FOR2(i, a, n) __FOR3(i, a, n, 1)
#define __FOR1(i, n) __FOR2(i, 0, n)
#define FOR(...) GET_MACRO(__VA_ARGS__, __FOR3, __FOR2, __FOR1)(__VA_ARGS__)

#define BOOST 			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ELO             exit(0)
#define ALL(a) 			(a).begin(), (a).end()
#define SZ(a) 			(int)(a).size()
#define TRAV(a, b) 		for (auto& a : b)
#define REV(a)          reverse(ALL(a))
#define SORT(a)         sort(ALL(a))
#define SORTR(a)        SORT(a), REV(a)
#define PB              push_back
#define F               first
#define S               second
using ll = 				long long;
using ld = 				long double; // 'long double' is 2.2 times slower than double
using pii = 			pair<int, int>;
using pll = 			pair<ll, ll>;
using pld =             pair<ld, ld>;
using vi = 				vector<int>;
using vvi =             vector<vi>;
using vll = 			vector<ll>;
using vvll =            vector<vll>;
using vpii = 			vector<pii>;
using vpll = 			vector<pll>;
using vld =             vector<ld>;
using vpld =            vector<pld>;

constexpr int MOD = 1e9 + 7; // 998244353
constexpr int INF = MOD;
constexpr ll LLINF = 1e18;
const ld PI = acos(-1);

template <class T> inline bool setmin(T& a, T b) {if (a > b) return a = b, 1; return 0; }
template <class T> inline bool setmax(T& a, T b) {if (a < b) return a = b, 1; return 0; }

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <class key, class cmp = less<key>> using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template <class key, class cmp = less_equal<key>> using ordered_multiset = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
//* find_by_order(k) - returns an iterator to the k-th largest element (counting from zero)
//* order_of_key(k)  - the number of items in a set that are strictly smaller than k.
template <class key, class value, class cmp = less<key>> using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
using pref_trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;
// * prefix_range(s) - return iterator range, prefix equal to s

namespace input {
    template <class T> istream &operator>>(istream &os, vector<T> & vec) { for (auto& u : vec) os >> u; return os; }
    template<class T1, class T2> istream& operator>>(istream& os, pair<T1, T2>& p) { return os >> p.first >> p.second; }
    template <class T, size_t N> istream& operator>>(istream& os, array<T, N>& a) { for (auto& u : a) os >> u; return os; }

    void re() {}
    template <typename T, typename... args> void re(T& x, args&... tail) { cin >> x; re(tail...); }
} // namespace input
using namespace input;

namespace output {
    template <class T> ostream &operator<<(ostream &os, const vector<T> & vec){for (const auto& u : vec) os << u << " "; return os; }
    template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << p.first << " " << p.second; }
    template <class T> ostream &operator<<(ostream &os, set<T> & con) { for (const auto& u : con) os << u << " "; return os; }
    template <class T, size_t N> ostream& operator<<(ostream& os, array<T, N>& a) { for (const auto& u : a) os << u << " "; return os; }

    void pr() {}
    template <typename T> void pr(const T& x) { cout << x; }
    template <typename T, typename... args> void pr(const T& x, const args&... tail) { cout << x << " "; pr(tail...);}
    template <typename T> void prs(const T& x) { cout << x << " "; }
    template <typename T, typename... args> void prs(const T& x, const args&... tail) { cout << x << " "; prs(tail...);}
    template <typename... args> void prln(const args&... tail) { pr(tail...); cout << "\n";}
} // namespace output
using namespace output;

namespace pair_magic {
	#define PT1T2 pair<T1,T2>
	#define TT1T2 template<class T1, class T2>
	TT1T2 inline PT1T2 operator+(const PT1T2 &p1, const PT1T2 &p2) { return PT1T2(p1.first + p2.first, p1.second + p2.second); }
	TT1T2 inline PT1T2& operator+=(PT1T2 &p1, const PT1T2 &p2) { p1.first += p2.first, p1.second += p2.second; return p1; }
	TT1T2 inline PT1T2 operator-(const PT1T2 &p1, const PT1T2 &p2) { return PT1T2(p1.first - p2.first, p1.second - p2.second); }
	TT1T2 inline PT1T2& operator-=(PT1T2 &p1, const PT1T2 &p2) { p1.first -= p2.first, p1.second -= p2.second; return p1; }
	#undef PT1T2
	#undef TT1T2
}
using namespace pair_magic;

namespace random_nsp {
	thread_local std::mt19937 gen{std::random_device{}()};
	template <typename T>T random(T min, T max){using dist = std::conditional_t<std::is_integral<T>::value, std::uniform_int_distribution<T>, std::uniform_real_distribution<T>>;return dist{min, max}(gen);}
	template <typename T> T randomINT(T min, T max) { return std::uniform_int_distribution<T>{min, max}(gen); }
}
using namespace random_nsp;

namespace triple {
	#define TT1T2T3 template<class T1, class T2, class T3>
	#define TRT1T2T3  triple<T1, T2, T3>
	TT1T2T3 struct triple { T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c) {} };
	TT1T2T3 bool operator<(const TRT1T2T3&t1, const TRT1T2T3&t2) { if (t1.a != t2.a)return t1.a < t2.a; else if (t1.b != t2.b)return t1.b < t2.b; else return t1.c < t2.c; }
	TT1T2T3 bool operator>(const TRT1T2T3&t1, const TRT1T2T3&t2) { if (t1.a != t2.a)return t1.a > t2.a; else if (t1.b != t2.b)return t1.b > t2.b; else return t1.c > t2.c; }
	TT1T2T3 bool operator==(const TRT1T2T3&t1, const TRT1T2T3&t2) { return (t1.a == t2.a && t1.b == t2.b && t1.c == t2.c); }
	TT1T2T3 inline istream& operator >> (istream& os, triple<T1, T2, T3>& t) { return os >> t.a >> t.b >> t.c; }
	TT1T2T3 ostream& operator << (ostream& os, const triple<T1, T2, T3>& t) { return os << t.a << " " << t.b << " " << t.c; }
	#undef TRT1T2T3
	#undef TT1T2T3
	using tri =  triple<int, int, int>;
	using trll = triple<ll, ll, ll>;
	using vtri = vector<tri>;
    using vtrll = vector<trll>;
}
using namespace triple;

template <class T> T invGeneral(T a, T b) { // 0 < a < b, gcd(a,b) = 1
    a %= b;
    if (a == 0) return b == 1 ? 0 : -1;
    T x = invGeneral(b, a);
    return x == -1 ? -1 : ((1-(ll)b * x) / a + b) % b;
}

template<class T, int MOD> struct modular {
	T val;
	explicit operator T() const { return val; }
	modular() { val = 0; }
	modular(const ll& v) {
		val = (-MOD <= v && v <= MOD) ? v : v % MOD;
		if (val < 0) val += MOD;
	}

	friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }
	friend void pr(const modular& a) { pr(a.val); }
	friend void re(modular& a) { ll x; re(x); a = modular(x); }

	friend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }
	friend bool operator!=(const modular& a, const modular& b) { return !(a == b); }
	friend bool operator<(const modular& a, const modular& b) { return a.val < b.val; }

	modular operator-() const { return modular(-val); }
	modular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	modular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	modular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }
	friend modular pow(modular a, ll p) {
		modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend modular inv(const modular& a) {
		auto i = invGeneral(a.val,MOD); assert(i != -1);
		return i;
	} // equivalent to return exp(b,MOD-2) if MOD is prime
	modular& operator/=(const modular& m) { return (*this) *= inv(m); }

	friend modular operator+(modular a, const modular& b) { return a += b; }
	friend modular operator-(modular a, const modular& b) { return a -= b; }
	friend modular operator*(modular a, const modular& b) { return a *= b; }
	friend modular operator/(modular a, const modular& b) { return a /= b; }
};

using mi = modular<int, MOD>;
using pmi = pair<mi,mi>;
using vmi = vector<mi>;
using vpmi = vector<pmi>;

namespace debug {
    template < typename _T > inline void _debug(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
    template < typename _T, typename... args > void _debug(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _debug(s + 1, a...); }

    #if 1
        #define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__)
        #define cerr cout
    #else
        #define debug(...) 1999
        #define cerr if(0) cout
    #endif
} // namespace debug
using namespace debug;

//////////////_________CODE_________//////////////

int main() {
    BOOST;
    int n; re(n);
	FOR(i, n) {
		FOR(j, n) {
			prs(j * n + i + 1);
		}
		prln();
	}
}


// #pragma GCC optimize("O3")
// #pragma GCC target("sse4")

#include <bits/stdc++.h>

using namespace std;

#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define __FOR3(i, a, n, inc) for(int i = (a); (inc) > 0 ? i < (n) : i >= (n); i += (inc))
#define __FOR2(i, a, n) __FOR3(i, a, n, 1)
#define __FOR1(i, n) __FOR2(i, 0, n)
#define FOR(...) GET_MACRO(__VA_ARGS__, __FOR3, __FOR2, __FOR1)(__VA_ARGS__)

#define BOOST 			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ELO             exit(0)
#define ALL(a) 			(a).begin(), (a).end()
#define SZ(a) 			(int)(a).size()
#define TRAV(a, b) 		for (auto& a : b)
#define REV(a)          reverse(ALL(a))
#define SORT(a)         sort(ALL(a))
#define SORTR(a)        SORT(a), REV(a)
#define PB              push_back
#define F               first
#define S               second
using ll = 				long long;
using ld = 				long double; // 'long double' is 2.2 times slower than double
using pii = 			pair<int, int>;
using pll = 			pair<ll, ll>;
using pld =             pair<ld, ld>;
using vi = 				vector<int>;
using vvi =             vector<vi>;
using vll = 			vector<ll>;
using vvll =            vector<vll>;
using vpii = 			vector<pii>;
using vpll = 			vector<pll>;
using vld =             vector<ld>;
using vpld =            vector<pld>;

constexpr int MOD = 1e9 + 7; // 998244353
constexpr int INF = MOD;
constexpr ll LLINF = 1e18;
const ld PI = acos(-1);

template <class T> inline bool setmin(T& a, T b) {if (a > b) return a = b, 1; return 0; }
template <class T> inline bool setmax(T& a, T b) {if (a < b) return a = b, 1; return 0; }

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <class key, class cmp = less<key>> using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template <class key, class cmp = less_equal<key>> using ordered_multiset = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
//* find_by_order(k) - returns an iterator to the k-th largest element (counting from zero)
//* order_of_key(k)  - the number of items in a set that are strictly smaller than k.
template <class key, class value, class cmp = less<key>> using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
using pref_trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;
// * prefix_range(s) - return iterator range, prefix equal to s

namespace input {
    template <class T> istream &operator>>(istream &os, vector<T> & vec) { for (auto& u : vec) os >> u; return os; }
    template<class T1, class T2> istream& operator>>(istream& os, pair<T1, T2>& p) { return os >> p.first >> p.second; }
    template <class T, size_t N> istream& operator>>(istream& os, array<T, N>& a) { for (auto& u : a) os >> u; return os; }

    void re() {}
    template <typename T, typename... args> void re(T& x, args&... tail) { cin >> x; re(tail...); }
} // namespace input
using namespace input;

namespace output {
    template <class T> ostream &operator<<(ostream &os, const vector<T> & vec){for (const auto& u : vec) os << u << " "; return os; }
    template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << p.first << " " << p.second; }
    template <class T> ostream &operator<<(ostream &os, set<T> & con) { for (const auto& u : con) os << u << " "; return os; }
    template <class T, size_t N> ostream& operator<<(ostream& os, array<T, N>& a) { for (const auto& u : a) os << u << " "; return os; }

    void pr() {}
    template <typename T> void pr(const T& x) { cout << x; }
    template <typename T, typename... args> void pr(const T& x, const args&... tail) { cout << x << " "; pr(tail...);}
    template <typename T> void prs(const T& x) { cout << x << " "; }
    template <typename T, typename... args> void prs(const T& x, const args&... tail) { cout << x << " "; prs(tail...);}
    template <typename... args> void prln(const args&... tail) { pr(tail...); cout << "\n";}
} // namespace output
using namespace output;

namespace pair_magic {
	#define PT1T2 pair<T1,T2>
	#define TT1T2 template<class T1, class T2>
	TT1T2 inline PT1T2 operator+(const PT1T2 &p1, const PT1T2 &p2) { return PT1T2(p1.first + p2.first, p1.second + p2.second); }
	TT1T2 inline PT1T2& operator+=(PT1T2 &p1, const PT1T2 &p2) { p1.first += p2.first, p1.second += p2.second; return p1; }
	TT1T2 inline PT1T2 operator-(const PT1T2 &p1, const PT1T2 &p2) { return PT1T2(p1.first - p2.first, p1.second - p2.second); }
	TT1T2 inline PT1T2& operator-=(PT1T2 &p1, const PT1T2 &p2) { p1.first -= p2.first, p1.second -= p2.second; return p1; }
	#undef PT1T2
	#undef TT1T2
}
using namespace pair_magic;

namespace random_nsp {
	thread_local std::mt19937 gen{std::random_device{}()};
	template <typename T>T random(T min, T max){using dist = std::conditional_t<std::is_integral<T>::value, std::uniform_int_distribution<T>, std::uniform_real_distribution<T>>;return dist{min, max}(gen);}
	template <typename T> T randomINT(T min, T max) { return std::uniform_int_distribution<T>{min, max}(gen); }
}
using namespace random_nsp;

namespace triple {
	#define TT1T2T3 template<class T1, class T2, class T3>
	#define TRT1T2T3  triple<T1, T2, T3>
	TT1T2T3 struct triple { T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c) {} };
	TT1T2T3 bool operator<(const TRT1T2T3&t1, const TRT1T2T3&t2) { if (t1.a != t2.a)return t1.a < t2.a; else if (t1.b != t2.b)return t1.b < t2.b; else return t1.c < t2.c; }
	TT1T2T3 bool operator>(const TRT1T2T3&t1, const TRT1T2T3&t2) { if (t1.a != t2.a)return t1.a > t2.a; else if (t1.b != t2.b)return t1.b > t2.b; else return t1.c > t2.c; }
	TT1T2T3 bool operator==(const TRT1T2T3&t1, const TRT1T2T3&t2) { return (t1.a == t2.a && t1.b == t2.b && t1.c == t2.c); }
	TT1T2T3 inline istream& operator >> (istream& os, triple<T1, T2, T3>& t) { return os >> t.a >> t.b >> t.c; }
	TT1T2T3 ostream& operator << (ostream& os, const triple<T1, T2, T3>& t) { return os << t.a << " " << t.b << " " << t.c; }
	#undef TRT1T2T3
	#undef TT1T2T3
	using tri =  triple<int, int, int>;
	using trll = triple<ll, ll, ll>;
	using vtri = vector<tri>;
    using vtrll = vector<trll>;
}
using namespace triple;

template <class T> T invGeneral(T a, T b) { // 0 < a < b, gcd(a,b) = 1
    a %= b;
    if (a == 0) return b == 1 ? 0 : -1;
    T x = invGeneral(b, a);
    return x == -1 ? -1 : ((1-(ll)b * x) / a + b) % b;
}

template<class T, int MOD> struct modular {
	T val;
	explicit operator T() const { return val; }
	modular() { val = 0; }
	modular(const ll& v) {
		val = (-MOD <= v && v <= MOD) ? v : v % MOD;
		if (val < 0) val += MOD;
	}

	friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }
	friend void pr(const modular& a) { pr(a.val); }
	friend void re(modular& a) { ll x; re(x); a = modular(x); }

	friend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }
	friend bool operator!=(const modular& a, const modular& b) { return !(a == b); }
	friend bool operator<(const modular& a, const modular& b) { return a.val < b.val; }

	modular operator-() const { return modular(-val); }
	modular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	modular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	modular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }
	friend modular pow(modular a, ll p) {
		modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend modular inv(const modular& a) {
		auto i = invGeneral(a.val,MOD); assert(i != -1);
		return i;
	} // equivalent to return exp(b,MOD-2) if MOD is prime
	modular& operator/=(const modular& m) { return (*this) *= inv(m); }

	friend modular operator+(modular a, const modular& b) { return a += b; }
	friend modular operator-(modular a, const modular& b) { return a -= b; }
	friend modular operator*(modular a, const modular& b) { return a *= b; }
	friend modular operator/(modular a, const modular& b) { return a /= b; }
};

using mi = modular<int, MOD>;
using pmi = pair<mi,mi>;
using vmi = vector<mi>;
using vpmi = vector<pmi>;

namespace debug {
    template < typename _T > inline void _debug(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
    template < typename _T, typename... args > void _debug(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _debug(s + 1, a...); }

    #if 1
        #define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__)
        #define cerr cout
    #else
        #define debug(...) 1999
        #define cerr if(0) cout
    #endif
} // namespace debug
using namespace debug;

//////////////_________CODE_________//////////////

int main() {
    BOOST;
    int n; re(n);

	vvi res(n);

	FOR(i, n) {
		FOR(j, n) {
			int id = i * n + j;
			int poz = j;
			if(i % 2 == 1) {
				poz = n - 1 - poz;
			}
			res[poz].PB(id + 1);
		}
	}

	FOR(i, n) {
		prln(res[i]);
	}
}


// #pragma GCC optimize("O3")
// #pragma GCC target("sse4")

#include <bits/stdc++.h>

using namespace std;

#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define __FOR3(i, a, n, inc) for(int i = (a); (inc) > 0 ? i < (n) : i >= (n); i += (inc))
#define __FOR2(i, a, n) __FOR3(i, a, n, 1)
#define __FOR1(i, n) __FOR2(i, 0, n)
#define FOR(...) GET_MACRO(__VA_ARGS__, __FOR3, __FOR2, __FOR1)(__VA_ARGS__)

#define BOOST 			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ELO             exit(0)
#define ALL(a) 			(a).begin(), (a).end()
#define SZ(a) 			(int)(a).size()
#define TRAV(a, b) 		for (auto& a : b)
#define REV(a)          reverse(ALL(a))
#define SORT(a)         sort(ALL(a))
#define SORTR(a)        SORT(a), REV(a)
#define PB              push_back
#define F               first
#define S               second
using ll = 				long long;
using ld = 				long double; // 'long double' is 2.2 times slower than double
using pii = 			pair<int, int>;
using pll = 			pair<ll, ll>;
using pld =             pair<ld, ld>;
using vi = 				vector<int>;
using vvi =             vector<vi>;
using vll = 			vector<ll>;
using vvll =            vector<vll>;
using vpii = 			vector<pii>;
using vpll = 			vector<pll>;
using vld =             vector<ld>;
using vpld =            vector<pld>;

constexpr int MOD = 1e9 + 7; // 998244353
constexpr int INF = MOD;
constexpr ll LLINF = 1e18;
const ld PI = acos(-1);

template <class T> inline bool setmin(T& a, T b) {if (a > b) return a = b, 1; return 0; }
template <class T> inline bool setmax(T& a, T b) {if (a < b) return a = b, 1; return 0; }

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <class key, class cmp = less<key>> using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template <class key, class cmp = less_equal<key>> using ordered_multiset = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
//* find_by_order(k) - returns an iterator to the k-th largest element (counting from zero)
//* order_of_key(k)  - the number of items in a set that are strictly smaller than k.
template <class key, class value, class cmp = less<key>> using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
using pref_trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;
// * prefix_range(s) - return iterator range, prefix equal to s

namespace input {
    template <class T> istream &operator>>(istream &os, vector<T> & vec) { for (auto& u : vec) os >> u; return os; }
    template<class T1, class T2> istream& operator>>(istream& os, pair<T1, T2>& p) { return os >> p.first >> p.second; }
    template <class T, size_t N> istream& operator>>(istream& os, array<T, N>& a) { for (auto& u : a) os >> u; return os; }

    void re() {}
    template <typename T, typename... args> void re(T& x, args&... tail) { cin >> x; re(tail...); }
} // namespace input
using namespace input;

namespace output {
    template <class T> ostream &operator<<(ostream &os, const vector<T> & vec){for (const auto& u : vec) os << u << " "; return os; }
    template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << p.first << " " << p.second; }
    template <class T> ostream &operator<<(ostream &os, set<T> & con) { for (const auto& u : con) os << u << " "; return os; }
    template <class T, size_t N> ostream& operator<<(ostream& os, array<T, N>& a) { for (const auto& u : a) os << u << " "; return os; }

    void pr() {}
    template <typename T> void pr(const T& x) { cout << x; }
    template <typename T, typename... args> void pr(const T& x, const args&... tail) { cout << x << " "; pr(tail...);}
    template <typename T> void prs(const T& x) { cout << x << " "; }
    template <typename T, typename... args> void prs(const T& x, const args&... tail) { cout << x << " "; prs(tail...);}
    template <typename... args> void prln(const args&... tail) { pr(tail...); cout << "\n";}
} // namespace output
using namespace output;

namespace pair_magic {
	#define PT1T2 pair<T1,T2>
	#define TT1T2 template<class T1, class T2>
	TT1T2 inline PT1T2 operator+(const PT1T2 &p1, const PT1T2 &p2) { return PT1T2(p1.first + p2.first, p1.second + p2.second); }
	TT1T2 inline PT1T2& operator+=(PT1T2 &p1, const PT1T2 &p2) { p1.first += p2.first, p1.second += p2.second; return p1; }
	TT1T2 inline PT1T2 operator-(const PT1T2 &p1, const PT1T2 &p2) { return PT1T2(p1.first - p2.first, p1.second - p2.second); }
	TT1T2 inline PT1T2& operator-=(PT1T2 &p1, const PT1T2 &p2) { p1.first -= p2.first, p1.second -= p2.second; return p1; }
	#undef PT1T2
	#undef TT1T2
}
using namespace pair_magic;

namespace random_nsp {
	thread_local std::mt19937 gen{std::random_device{}()};
	template <typename T>T random(T min, T max){using dist = std::conditional_t<std::is_integral<T>::value, std::uniform_int_distribution<T>, std::uniform_real_distribution<T>>;return dist{min, max}(gen);}
	template <typename T> T randomINT(T min, T max) { return std::uniform_int_distribution<T>{min, max}(gen); }
}
using namespace random_nsp;

namespace triple {
	#define TT1T2T3 template<class T1, class T2, class T3>
	#define TRT1T2T3  triple<T1, T2, T3>
	TT1T2T3 struct triple { T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c) {} };
	TT1T2T3 bool operator<(const TRT1T2T3&t1, const TRT1T2T3&t2) { if (t1.a != t2.a)return t1.a < t2.a; else if (t1.b != t2.b)return t1.b < t2.b; else return t1.c < t2.c; }
	TT1T2T3 bool operator>(const TRT1T2T3&t1, const TRT1T2T3&t2) { if (t1.a != t2.a)return t1.a > t2.a; else if (t1.b != t2.b)return t1.b > t2.b; else return t1.c > t2.c; }
	TT1T2T3 bool operator==(const TRT1T2T3&t1, const TRT1T2T3&t2) { return (t1.a == t2.a && t1.b == t2.b && t1.c == t2.c); }
	TT1T2T3 inline istream& operator >> (istream& os, triple<T1, T2, T3>& t) { return os >> t.a >> t.b >> t.c; }
	TT1T2T3 ostream& operator << (ostream& os, const triple<T1, T2, T3>& t) { return os << t.a << " " << t.b << " " << t.c; }
	#undef TRT1T2T3
	#undef TT1T2T3
	using tri =  triple<int, int, int>;
	using trll = triple<ll, ll, ll>;
	using vtri = vector<tri>;
    using vtrll = vector<trll>;
}
using namespace triple;

template <class T> T invGeneral(T a, T b) { // 0 < a < b, gcd(a,b) = 1
    a %= b;
    if (a == 0) return b == 1 ? 0 : -1;
    T x = invGeneral(b, a);
    return x == -1 ? -1 : ((1-(ll)b * x) / a + b) % b;
}

template<class T, int MOD> struct modular {
	T val;
	explicit operator T() const { return val; }
	modular() { val = 0; }
	modular(const ll& v) {
		val = (-MOD <= v && v <= MOD) ? v : v % MOD;
		if (val < 0) val += MOD;
	}

	friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }
	friend void pr(const modular& a) { pr(a.val); }
	friend void re(modular& a) { ll x; re(x); a = modular(x); }

	friend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }
	friend bool operator!=(const modular& a, const modular& b) { return !(a == b); }
	friend bool operator<(const modular& a, const modular& b) { return a.val < b.val; }

	modular operator-() const { return modular(-val); }
	modular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	modular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	modular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }
	friend modular pow(modular a, ll p) {
		modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend modular inv(const modular& a) {
		auto i = invGeneral(a.val,MOD); assert(i != -1);
		return i;
	} // equivalent to return exp(b,MOD-2) if MOD is prime
	modular& operator/=(const modular& m) { return (*this) *= inv(m); }

	friend modular operator+(modular a, const modular& b) { return a += b; }
	friend modular operator-(modular a, const modular& b) { return a -= b; }
	friend modular operator*(modular a, const modular& b) { return a *= b; }
	friend modular operator/(modular a, const modular& b) { return a /= b; }
};

using mi = modular<int, MOD>;
using pmi = pair<mi,mi>;
using vmi = vector<mi>;
using vpmi = vector<pmi>;

namespace debug {
    template < typename _T > inline void _debug(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
    template < typename _T, typename... args > void _debug(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _debug(s + 1, a...); }

    #if 1
        #define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__)
        #define cerr cout
    #else
        #define debug(...) 1999
        #define cerr if(0) cout
    #endif
} // namespace debug
using namespace debug;

//////////////_________CODE_________//////////////

int main() {
    BOOST;
    int n; re(n);

	vi perm(n * n);

	int i = 0, j = n * n - 1;
	FOR(x, n) {
		int l = n / 2;
		int r = n - l;
		FOR(y, l) {
			perm[i++] = x;
		}
		FOR(y, r) {
			perm[j--] = x;
		}
	}

	vvi res(n);
	FOR(i, n) {
		FOR(j, n) {
			int id = i * n + j;
			res[perm[id]].PB(id + 1);
		}
	}

	FOR(i, n) {
		prln(res[i]);
	}
}


    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main(){
        ll n;
        cin>>n;
        ll arr[305][305];
        ll k=0;
        ll last=0;
        ll h = (n+1)/2;
        for(ll j=0;j<h;j++){
        for(ll i=0;i<n;i++){
            arr[i][k] = last+1;
            if(k+1 < n)
            arr[i][k+1] = (n*n)-last;
            last++;
        }
        k+=2;
        }
        for(ll i=0;i<n;i++){
            for(ll j=0;j<n;j++){
                cout<<arr[i][j]<<" ";
            }
            cout<<endl;
        }
    }


    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main(){
        ll n;
        cin>>n;
        int arr[305][305];
        int k=0;
        int last=0;
        for(int j=0;j<n-1;j++){
        for(int i=0;i<n;i++){
            arr[i][k] = last+1;
            if(k+1 < n)
            arr[i][k+1] = (n*n)-last;
            last++;
        }
        k+=2;
        }
        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;
    typedef long long ll;
    int main(){
        ll n;
        cin>>n;
        ll arr[305][305];
        ll k=0;
        ll last=0;
        for(ll j=0;j<n-1;j++){
        for(ll i=0;i<n;i++){
            arr[i][k] = last+1;
            if(k+1 < n)
            arr[i][k+1] = (n*n)-last;
            last++;
        }
        k+=2;
        }
        for(ll i=0;i<n;i++){
            for(ll j=0;j<n;j++){
                cout<<arr[i][j]<<" ";
            }
            cout<<endl;
        }
    }


    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main(){
        ll n;
        cin>>n;
        for(int i=0;i<n;i++){
            int k=i+1;
            for(int j=0;j<n;j++){
                cout<<k<<" ";
                k+=n;
            }
            cout<<endl;
        }
    }


    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main(){
        ll n;
        cin>>n;
        for(int i=0;i<n;i++){
            int k=i+1;
            for(int j=0;j<n;j++){
               // cout<<k<<" ";
                if(j == n-1){
                    k = (n*n)-i;
                }
                    cout<<k<<" ";
                k+=n;
            }
            cout<<endl;
        }
    }


    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll mod = 1e9+7;
    long long power(long long a,long long b){
    long long ans;
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ans = power(a,b/2);
    ans = ans * ans;
    ans %= mod;
    if(b%2==1){
        ans = ans * a;
    }
    ans %= mod;
    return ans%mod;
}
    int main(){
        ll n,m;
        cin>>n>>m;
        ll ans = power(2,m);
        ans--;
        if(ans == -1){
            ans = 1e9+7-1;
        }
        n--;
        ll k=0;
        for(ll i=0;i<m;i++){
            k+=i+1;
            k %= mod;
        }
        k %= mod;
        while(n--){
            ans = k  * ans;
            ans %= mod;
        }
        cout<<ans;
    }


    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main(){
        ll n;
        cin>>n;
        int arr[n][n];
        int k=0;
        int last=0;
        for(int j=0;j<n-1;j++){
        for(int i=0;i<n;i++){
            arr[i][k] = last+1;
            if(k+1 < n)
            arr[i][k+1] = (n*n)-last;
            last++;
        }
        k+=2;
        }
        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;
        typedef long long ll;
        ll mod = 1e9+7;
        long long power(long long a,long long b){
        long long ans;
        if(b == 0)
            return 1;
        if(b == 1)
            return a;
        ans = power(a,b/2);
        ans = ans * ans;
        ans %= mod;
        if(b%2==1){
            ans = ans * a;
        }
        ans %= mod;
        return ans;
    }
        int main(){
            ll n,m;
            cin>>n>>m;
            ll ans = power(2,m);
            ans--;
            ans %= mod;
            if(n == 1){
                cout<<ans;
                return 0;
            }
            ll k=(m+1)*m;
            k/=2;
            k %= mod;
            n--;
            ans *= power(k,n);
            ans %= mod;
            cout<<ans;
        }


    #include<bits/stdc++.h>
        using namespace std;
        typedef long long ll;
        ll mod = 1e9+7;
        long long power(long long a,long long b){
        long long ans;
        if(b == 0)
            return 1;
        if(b == 1)
            return a;
        ans = power(a,b/2);
        ans = ans * ans;
        ans %= mod;
        if(b%2==1){
            ans = ans * a;
        }
        ans %= mod;
        return ans%mod;
    }
        int main(){
            ll n,m;
            cin>>n>>m;
            ll ans = power(2,m);
            ans--;
            if(n == 1){
                cout<<ans;
                return 0;
            }
            ll k=(1+m)*m;
            k/=2;
            k %= mod;
            n--;
            ans *= power(k,n);
            ans %= mod;
            cout<<ans;
        }


            #include<bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                ll mod = 1e9+7;
        ll power(ll x,  ll y)
        {
            ll temp;
            if( y == 0)
                return 1;
            temp = power(x, y/2)%mod;
            if (y%2 == 0)
                return (temp*temp)%mod;
            else
                return (x*temp*temp)%mod;
        }
                int main(){
                    ll n,m;
                    cin>>n>>m;
                    ll ans = power(2,m);
                    ans--;
                    ans %= mod;
                    if(n == 1){
                        cout<<ans;
                        return 0;
                    }
                    ans = power(ans,m);
                    ans %= mod;
                    cout<<ans;
                }


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

int main(){

        int n;
        cin>>n;
        int arr[n+1][n+1];
        bool flag=true;
        int val=1;
        int x=1;
        while(x<=n){
            if(flag==true){
                for(int i=1;i<=n;i++){
                    arr[i][x]=val++;
                }
                flag=false;
                x++;
            }else{
                for(int i=n;i>=1;i--){
                    arr[i][x]=val++;
                }
                flag=true;
                x++;
            }
        }

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

}


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

int main(){

        int n;
        cin>>n;
        vector<vector<int>> ans( n+1 , vector<int> (n+1));
        bool flag=true;
        int val=1;
        while(n--){
            if(flag==true){
                for(int i=1;i<=n;i++){
                    ans[i].push_back(val++);
                }
                flag=false;
            }else{
                for(int i=n;i>=1;i--){
                    ans[i].push_back(val++);
                }
                flag=true;
            }
        }

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

        }

}


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

int main(){

        int n;
        cin>>n;
        int arr[n][n];
        bool flag=true;
        int val=1;
        int x=1;
        while(x<=n){
            if(flag==true){
                for(int i=1;i<=n;i++){
                    arr[i][x]=val++;
                }
                flag=false;
                x++;
            }else{
                for(int i=n;i>=1;i--){
                    arr[i][x]=val++;
                }
                flag=true;
                x++;
            }
        }

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

}


#include <bits/stdc++.h>

using namespace std;

const int N = 310;

int ans[N][N];

int n;

int main()
{
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);

    ios :: sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    for(int j=0;j<n;j++)
        for(int i=0;i<n;i++)
        {
            int cur = j * n + (j + i) % n;
            ans[i][j] = cur + 1;
        }

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

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 310;

int ans[N][N];

int n;

int main()
{
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);

    ios :: sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    for(int j=0;j<n;j++)
        for(int i=0;i<n;i++)
        {
            int cur = j * n + i + 1;
            if(j & 1) ans[n - i - 1][j] = cur;
            else ans[i][j] = cur;
        }

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

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 310;

int ans[N][N];

int n;

int main()
{
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);

    ios :: sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            int cur = (j - 1) * n + (i - 1 + j) % n + 1;
            ans[i][j] = cur;
        }

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

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 310;

int ans[N][N];

int n;

int main()
{
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);

    ios :: sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    for(int j=1;j<=n;j++)
        for(int i=1;i<=n;i++)
        {
            int cur = (j - 1) * n + (i - 2 + j) % n + 1;
            ans[i][j] = cur;
        }

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

    return 0;
}


    #include<iostream>
    #include<string>
    #include<vector>
    #include<algorithm>
    #include<cmath>
    #include<iomanip>
    #include<stack>
    #include<bits/stdc++.h>
    #include<stdint.h>
    //#include <boost/rational.hpp>
    //#include <boost/multiprecision/cpp_int.hpp>
    #define EPSILON 2.2204460492503131e-16
    //typedef long long int ll
    ///			std::cout << std::fixed;
    ///    		std::cout << std::setprecision(8);
    // 			upper_bound(arr,arr+11,7)-arr
    ///			__gcd(a,b);
    //			abs();
    //			min(a,b)	max(a,b)
    //			*max_element(arr,arr+n)		*min_element(arr,arr+n)
    //			count(arr,arr+n,a)  __(finds cunt of a)
    //			distance(arr,find(arr,arr+n,a))
    //			memset(a, 0, sizeof(a));
    //			int64_t i,j,k;
    using namespace std;
    typedef long long ll;
    /*
    ll powe(ll n , ll m, ll mod)
    {
    	ll num,i,j;

    	if(m == 0)
    	    return 1;

    	if(m == 1)
    	return (n%mod);

    	if( !(m%2) )
    	{
    		num = powe(n,m/2,mod) % mod;
    		return (num*num)%mod;
    	}
    	else
    	{
    		num = powe(n,(m-1)/2,mod) % mod;
    		return ((n%mod)*((num*num)%mod))%mod;
    	}
    }
    ll primfac(ll num)
    {
    	if(num%2 == 0)
    	{
    		while( num%2 == 0)
    		{
    			mp[2]++;
    			num /= 2;
    		}
    	}
    	ll sq;
    //	sq = sqrt(num);
    	for(ll i=3;i<=sqrt(num);i += 2)
    	{
    		while( num%i == 0 )
    		{
    			mp[i]++;
    			num /= i;
    		}
    	}
    	if(num > 2)
    		mp[num]++;

    }
    ll inv(ll n,ll mod)
    {
    	return (powe(n,mod-2,mod)%mod);
    }
    ll ncr(ll n,ll r,ll mod)
    {
    	ll i,j,k;
    	if( (n < r) || (n<0) || (r<0) )
    	return 0;
    	return ( (((fact[n]%mod)*(inv(fact[n-r],mod)%mod))%mod) * (inv(fact[r],mod)%mod) );
    }

    inline bool mo_comp(const pair< pair<ll, ll>, ll> &x,const pair< pair<ll, ll>, ll> &y)
    {
        ll block_x = x.first.first / b_size;
        ll block_y = y.first.first / b_size;
        if(block_x != block_y)
            return block_x < block_y;
        return x.first.second < y.first.second;
    }
    */
    /*ll fnum=0,mat[50][2]={0};

    struct node
    {
    	map< ll , struct node *> mp;
    	ll en;
    };

    struct node* create_node()
    {
    	struct node *ptr;
    	ptr = new(node);
    	(*ptr).en = 0;

    	return ptr;
    }
    ll build_trie(struct node *head , ll bin[],ll in)
    {
    	ll j,k;
    	struct node *ptr;

    	if(in < 0)
    	return 0;

    	if( (*head).mp[bin[in]] == NULL )
    	{
    		ptr  = create_node();
    		(*head).mp[bin[in]] = ptr;
    		build_trie(ptr,bin,in-1);
    	}
    	else
    	{
    		ptr = (*head).mp[bin[in]];
    		build_trie(ptr,bin,in-1);
    	}
    	return 0;
    }

    ll findintrie(struct node* head,ll bin[],ll in)
    {
    	ll i,j,k;
    	struct node *ptr;

    	if( (in < 0) ){
    	return 0;}

    	if( (*head).mp[bin[in]] != NULL )
    	{
    		fnum += bin[in]*((ll)1<<in);
    		findintrie((*head).mp[bin[in]],bin,in-1);
    	}
    	else
    	{
    		fnum += ( abs(bin[in]-1)*((ll)1<<in) );
    		findintrie((*head).mp[abs(bin[in]-1)],bin,in-1);
    	}

    	return 0;

    }

    ll par[100005]={0},sz[100005]={0};
    ll find_root(ll a)
    {
    	ll b;
    	while( par[a] != a )
    	{
    		a = par[a];
    	}
    	par[b] = a;
    	return a;
    }

    ll unite(ll a, ll b)
    {
    	ll root_a,root_b;
    	root_a = find_root(a);
    	root_b = find_root(b);

    	if( root_a == root_b )
    		return 0;
    	if( sz[root_a] > sz[root_b] )
    	{
    		sz[root_a] += sz[root_b];
    		par[root_b] = root_a;
    	}
    	else
    	{
    		sz[root_b] += sz[root_a];
    		par[root_a] = root_b;
    	}

    	return 0;
    }
    */

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

    	ll n,i,j,k,count=0;
    	cin>>n;
    	vector< ll > v[500];
    	count=1;

		for(i=1;i<=n;i++){
		    v[i].push_back(0);
			for(j=1;j<=n;j++)
				v[i].push_back(count++);

		}

		for(i=1;i<=(n/2);i++)
		{
			for(j=1;j<=((n+1)/2);j++)
			{
				swap( v[i][j] , v[n-i+1][j] );
			}
		}

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

    	return 0;
    }


    #include<iostream>
    #include<string>
    #include<vector>
    #include<algorithm>
    #include<cmath>
    #include<iomanip>
    #include<stack>
    #include<bits/stdc++.h>
    #include<stdint.h>
    //#include <boost/rational.hpp>
    //#include <boost/multiprecision/cpp_int.hpp>
    #define EPSILON 2.2204460492503131e-16
    //typedef long long int ll
    ///			std::cout << std::fixed;
    ///    		std::cout << std::setprecision(8);
    // 			upper_bound(arr,arr+11,7)-arr
    ///			__gcd(a,b);
    //			abs();
    //			min(a,b)	max(a,b)
    //			*max_element(arr,arr+n)		*min_element(arr,arr+n)
    //			count(arr,arr+n,a)  __(finds cunt of a)
    //			distance(arr,find(arr,arr+n,a))
    //			memset(a, 0, sizeof(a));
    //			int64_t i,j,k;
    using namespace std;
    typedef long long ll;
    /*
    ll powe(ll n , ll m, ll mod)
    {
    	ll num,i,j;

    	if(m == 0)
    	    return 1;

    	if(m == 1)
    	return (n%mod);

    	if( !(m%2) )
    	{
    		num = powe(n,m/2,mod) % mod;
    		return (num*num)%mod;
    	}
    	else
    	{
    		num = powe(n,(m-1)/2,mod) % mod;
    		return ((n%mod)*((num*num)%mod))%mod;
    	}
    }
    ll primfac(ll num)
    {
    	if(num%2 == 0)
    	{
    		while( num%2 == 0)
    		{
    			mp[2]++;
    			num /= 2;
    		}
    	}
    	ll sq;
    //	sq = sqrt(num);
    	for(ll i=3;i<=sqrt(num);i += 2)
    	{
    		while( num%i == 0 )
    		{
    			mp[i]++;
    			num /= i;
    		}
    	}
    	if(num > 2)
    		mp[num]++;

    }
    ll inv(ll n,ll mod)
    {
    	return (powe(n,mod-2,mod)%mod);
    }
    ll ncr(ll n,ll r,ll mod)
    {
    	ll i,j,k;
    	if( (n < r) || (n<0) || (r<0) )
    	return 0;
    	return ( (((fact[n]%mod)*(inv(fact[n-r],mod)%mod))%mod) * (inv(fact[r],mod)%mod) );
    }

    inline bool mo_comp(const pair< pair<ll, ll>, ll> &x,const pair< pair<ll, ll>, ll> &y)
    {
        ll block_x = x.first.first / b_size;
        ll block_y = y.first.first / b_size;
        if(block_x != block_y)
            return block_x < block_y;
        return x.first.second < y.first.second;
    }
    */
    /*ll fnum=0,mat[50][2]={0};

    struct node
    {
    	map< ll , struct node *> mp;
    	ll en;
    };

    struct node* create_node()
    {
    	struct node *ptr;
    	ptr = new(node);
    	(*ptr).en = 0;

    	return ptr;
    }
    ll build_trie(struct node *head , ll bin[],ll in)
    {
    	ll j,k;
    	struct node *ptr;

    	if(in < 0)
    	return 0;

    	if( (*head).mp[bin[in]] == NULL )
    	{
    		ptr  = create_node();
    		(*head).mp[bin[in]] = ptr;
    		build_trie(ptr,bin,in-1);
    	}
    	else
    	{
    		ptr = (*head).mp[bin[in]];
    		build_trie(ptr,bin,in-1);
    	}
    	return 0;
    }

    ll findintrie(struct node* head,ll bin[],ll in)
    {
    	ll i,j,k;
    	struct node *ptr;

    	if( (in < 0) ){
    	return 0;}

    	if( (*head).mp[bin[in]] != NULL )
    	{
    		fnum += bin[in]*((ll)1<<in);
    		findintrie((*head).mp[bin[in]],bin,in-1);
    	}
    	else
    	{
    		fnum += ( abs(bin[in]-1)*((ll)1<<in) );
    		findintrie((*head).mp[abs(bin[in]-1)],bin,in-1);
    	}

    	return 0;

    }

    ll par[100005]={0},sz[100005]={0};
    ll find_root(ll a)
    {
    	ll b;
    	while( par[a] != a )
    	{
    		a = par[a];
    	}
    	par[b] = a;
    	return a;
    }

    ll unite(ll a, ll b)
    {
    	ll root_a,root_b;
    	root_a = find_root(a);
    	root_b = find_root(b);

    	if( root_a == root_b )
    		return 0;
    	if( sz[root_a] > sz[root_b] )
    	{
    		sz[root_a] += sz[root_b];
    		par[root_b] = root_a;
    	}
    	else
    	{
    		sz[root_b] += sz[root_a];
    		par[root_a] = root_b;
    	}

    	return 0;
    }
    */

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

    	ll n,i,j,k,count=0;
    	cin>>n;
    	vector< vector< ll > > v( 500 , vector< ll > (500 , 0) )  ;
//        vector< ll > v(100);
    	count=1;
		ll flag=1;
		for(i=1;i<=n;i++)
		{
			if(flag){
			for(j=1;j<=n;j++)
				v[j][i] = count++;
				flag=0;
			}
			else{
			for(j=n;j>=1;j--)
				v[j][i] = count++;
				flag=1;
			}

		}

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

    	return 0;
    }


    #include<iostream>
    #include<string>
    #include<vector>
    #include<algorithm>
    #include<cmath>
    #include<iomanip>
    #include<stack>
    #include<bits/stdc++.h>
    #include<stdint.h>
    //#include <boost/rational.hpp>
    //#include <boost/multiprecision/cpp_int.hpp>
    #define EPSILON 2.2204460492503131e-16
    //typedef long long int ll
    ///			std::cout << std::fixed;
    ///    		std::cout << std::setprecision(8);
    // 			upper_bound(arr,arr+11,7)-arr
    ///			__gcd(a,b);
    //			abs();
    //			min(a,b)	max(a,b)
    //			*max_element(arr,arr+n)		*min_element(arr,arr+n)
    //			count(arr,arr+n,a)  __(finds cunt of a)
    //			distance(arr,find(arr,arr+n,a))
    //			memset(a, 0, sizeof(a));
    //			int64_t i,j,k;
    using namespace std;
    typedef long long ll;
    /*
    ll powe(ll n , ll m, ll mod)
    {
    	ll num,i,j;

    	if(m == 0)
    	    return 1;

    	if(m == 1)
    	return (n%mod);

    	if( !(m%2) )
    	{
    		num = powe(n,m/2,mod) % mod;
    		return (num*num)%mod;
    	}
    	else
    	{
    		num = powe(n,(m-1)/2,mod) % mod;
    		return ((n%mod)*((num*num)%mod))%mod;
    	}
    }
    ll primfac(ll num)
    {
    	if(num%2 == 0)
    	{
    		while( num%2 == 0)
    		{
    			mp[2]++;
    			num /= 2;
    		}
    	}
    	ll sq;
    //	sq = sqrt(num);
    	for(ll i=3;i<=sqrt(num);i += 2)
    	{
    		while( num%i == 0 )
    		{
    			mp[i]++;
    			num /= i;
    		}
    	}
    	if(num > 2)
    		mp[num]++;

    }
    ll inv(ll n,ll mod)
    {
    	return (powe(n,mod-2,mod)%mod);
    }
    ll ncr(ll n,ll r,ll mod)
    {
    	ll i,j,k;
    	if( (n < r) || (n<0) || (r<0) )
    	return 0;
    	return ( (((fact[n]%mod)*(inv(fact[n-r],mod)%mod))%mod) * (inv(fact[r],mod)%mod) );
    }

    inline bool mo_comp(const pair< pair<ll, ll>, ll> &x,const pair< pair<ll, ll>, ll> &y)
    {
        ll block_x = x.first.first / b_size;
        ll block_y = y.first.first / b_size;
        if(block_x != block_y)
            return block_x < block_y;
        return x.first.second < y.first.second;
    }
    */
    /*ll fnum=0,mat[50][2]={0};

    struct node
    {
    	map< ll , struct node *> mp;
    	ll en;
    };

    struct node* create_node()
    {
    	struct node *ptr;
    	ptr = new(node);
    	(*ptr).en = 0;

    	return ptr;
    }
    ll build_trie(struct node *head , ll bin[],ll in)
    {
    	ll j,k;
    	struct node *ptr;

    	if(in < 0)
    	return 0;

    	if( (*head).mp[bin[in]] == NULL )
    	{
    		ptr  = create_node();
    		(*head).mp[bin[in]] = ptr;
    		build_trie(ptr,bin,in-1);
    	}
    	else
    	{
    		ptr = (*head).mp[bin[in]];
    		build_trie(ptr,bin,in-1);
    	}
    	return 0;
    }

    ll findintrie(struct node* head,ll bin[],ll in)
    {
    	ll i,j,k;
    	struct node *ptr;

    	if( (in < 0) ){
    	return 0;}

    	if( (*head).mp[bin[in]] != NULL )
    	{
    		fnum += bin[in]*((ll)1<<in);
    		findintrie((*head).mp[bin[in]],bin,in-1);
    	}
    	else
    	{
    		fnum += ( abs(bin[in]-1)*((ll)1<<in) );
    		findintrie((*head).mp[abs(bin[in]-1)],bin,in-1);
    	}

    	return 0;

    }

    ll par[100005]={0},sz[100005]={0};
    ll find_root(ll a)
    {
    	ll b;
    	while( par[a] != a )
    	{
    		a = par[a];
    	}
    	par[b] = a;
    	return a;
    }

    ll unite(ll a, ll b)
    {
    	ll root_a,root_b;
    	root_a = find_root(a);
    	root_b = find_root(b);

    	if( root_a == root_b )
    		return 0;
    	if( sz[root_a] > sz[root_b] )
    	{
    		sz[root_a] += sz[root_b];
    		par[root_b] = root_a;
    	}
    	else
    	{
    		sz[root_b] += sz[root_a];
    		par[root_a] = root_b;
    	}

    	return 0;
    }
    */

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

    	ll n,i,j,k,count=0;
    	cin>>n;
    	vector< ll > v[500];
    	count=1;

		for(i=1;i<=n;i++){
		    v[i].push_back(0);
			for(j=1;j<=n;j++)
				v[i].push_back(count++);

		}

		for(i=1;i<=(n/2);i++)
		{
			for(j=1;j<=(n/2);j++)
			{
				swap( v[i][j] , v[n-i+1][j] );
			}
		}

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

    	return 0;
    }


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<stack>
#include<bits/stdc++.h>
#include<stdint.h>
//#include <boost/rational.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#define EPSILON 2.2204460492503131e-16
//typedef long long int ll
///			std::cout << std::fixed;
///    		std::cout << std::setprecision(8);
// 			upper_bound(arr,arr+11,7)-arr
///			__gcd(a,b);
//			abs();
//			min(a,b)	max(a,b)
//			*max_element(arr,arr+n)		*min_element(arr,arr+n)
//			count(arr,arr+n,a)  __(finds cunt of a)
//			distance(arr,find(arr,arr+n,a))
//			memset(a, 0, sizeof(a));
//			int64_t i,j,k;
using namespace std;
typedef long long ll;
/*
ll powe(ll n , ll m, ll mod)
{
	ll num,i,j;

	if(m == 0)
	    return 1;

	if(m == 1)
	return (n%mod);

	if( !(m%2) )
	{
		num = powe(n,m/2,mod) % mod;
		return (num*num)%mod;
	}
	else
	{
		num = powe(n,(m-1)/2,mod) % mod;
		return ((n%mod)*((num*num)%mod))%mod;
	}
}
ll primfac(ll num)
{
	if(num%2 == 0)
	{
		while( num%2 == 0)
		{
			mp[2]++;
			num /= 2;
		}
	}
	ll sq;
//	sq = sqrt(num);
	for(ll i=3;i<=sqrt(num);i += 2)
	{
		while( num%i == 0 )
		{
			mp[i]++;
			num /= i;
		}
	}
	if(num > 2)
		mp[num]++;

}
ll inv(ll n,ll mod)
{
	return (powe(n,mod-2,mod)%mod);
}
ll ncr(ll n,ll r,ll mod)
{
	ll i,j,k;
	if( (n < r) || (n<0) || (r<0) )
	return 0;
	return ( (((fact[n]%mod)*(inv(fact[n-r],mod)%mod))%mod) * (inv(fact[r],mod)%mod) );
}

inline bool mo_comp(const pair< pair<ll, ll>, ll> &x,const pair< pair<ll, ll>, ll> &y)
{
    ll block_x = x.first.first / b_size;
    ll block_y = y.first.first / b_size;
    if(block_x != block_y)
        return block_x < block_y;
    return x.first.second < y.first.second;
}
*/
/*ll fnum=0,mat[50][2]={0};

struct node
{
	map< ll , struct node *> mp;
	ll en;
};

struct node* create_node()
{
	struct node *ptr;
	ptr = new(node);
	(*ptr).en = 0;

	return ptr;
}
ll build_trie(struct node *head , ll bin[],ll in)
{
	ll j,k;
	struct node *ptr;

	if(in < 0)
	return 0;

	if( (*head).mp[bin[in]] == NULL )
	{
		ptr  = create_node();
		(*head).mp[bin[in]] = ptr;
		build_trie(ptr,bin,in-1);
	}
	else
	{
		ptr = (*head).mp[bin[in]];
		build_trie(ptr,bin,in-1);
	}
	return 0;
}

ll findintrie(struct node* head,ll bin[],ll in)
{
	ll i,j,k;
	struct node *ptr;

	if( (in < 0) ){
	return 0;}

	if( (*head).mp[bin[in]] != NULL )
	{
		fnum += bin[in]*((ll)1<<in);
		findintrie((*head).mp[bin[in]],bin,in-1);
	}
	else
	{
		fnum += ( abs(bin[in]-1)*((ll)1<<in) );
		findintrie((*head).mp[abs(bin[in]-1)],bin,in-1);
	}

	return 0;

}

ll par[100005]={0},sz[100005]={0};
ll find_root(ll a)
{
	ll b;
	while( par[a] != a )
	{
		a = par[a];
	}
	par[b] = a;
	return a;
}

ll unite(ll a, ll b)
{
	ll root_a,root_b;
	root_a = find_root(a);
	root_b = find_root(b);

	if( root_a == root_b )
		return 0;
	if( sz[root_a] > sz[root_b] )
	{
		sz[root_a] += sz[root_b];
		par[root_b] = root_a;
	}
	else
	{
		sz[root_b] += sz[root_a];
		par[root_a] = root_b;
	}

	return 0;
}
*/

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

	ll n,i,j,k,count=0;
	cin>>n;
	vector< ll > v[500];
	count=1;
	for(i=0;i<n;i++)
	{
		for( j=0;j<n;j++ )
		{

			v[(i+j)%n].push_back(count);
				count++;
		}
	}

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

		cout<<"\n";
	}

	return 0;
}


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

int n, p[60000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) p[i * n + j] = i + j * n + 1;
    }
    int l = 0, r = n * n - 1;
    for (int i = 0; i < n; ++i) {
        int x = (i & 1) ? n / 2 : (n + 1) / 2;
        for (int j = 0; j < x; ++j) cout << p[l + j] << " ";
        l += x;
        for (int j = 0; j < n - x; ++j) cout << p[r - j] << " ";
        r -= n - x;
        cout << '\n';
    }
    return 0;
}


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

#define x first
#define y second
#define pb push_back
#define mp make_pair

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

int a[90000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < (n * n + 1) / 2; i++) a[i * 2] = i + 1;
    for (int i = 0; i < n * n / 2; i++) a[i * 2 + 1] = n * n - i;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) cout << a[i * n + j] << " ";
        cout << '\n';
    }
    return 0;
}


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

int n, p[90000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) p[i * n + j] = i + j * n + 1;
    }
    int l = 0, r = n * n - 1;
    for (int i = 0; i < n; ++i) {
        int x = (i & 1) ? n / 2 : (n + 1) / 2;
        for (int j = 0; j < x; ++j) cout << p[l + j] << " ";
        l += x;
        for (int j = 0; j < n - x; ++j) cout << p[r - j] << " ";
        r -= n - x;
        cout << '\n';
    }
    return 0;
}


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

int n, p[60000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) p[i * n + j] = i + j * n + 1;
    }
    int l = 0, r = n * n - 1;
    for (int i = 0; i < n; ++i) {
        int x = (i & 1) ? n / 2 : (n + 1) / 2;
        for (int j = 0; j < x; ++j) cout << p[l + j] << " ";
        l += x;
        for (int j = 0; j < n - x; ++j) cout << p[r - j] << " ";
        r -= n - x;
        cout << "\n"[i + 1 == n];
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

#define debug(x) cerr << #x << " = " << x << '\n'

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template<typename T = int>
inline T read() {
	T res = 0, sig = 1;
	char c = getchar();
	while ((c < '0' || c > '9') && c != '-') {
		c = getchar();
	}
	if (c == '-') {
		sig = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	return res * sig;
}

void setio(const char *in, const char *out) {
	freopen(in, "r", stdin);
	freopen(out, "w", stdout);
}

void fastio() {
	ios::sync_with_stdio(false);
	cin.tie(0);
}

int main() {
	fastio();
	int n;
	cin >> n;
	int l = 1, r = n * n;
	for (int i = 0; i < n; i++) {
		int a = n >> 1, b = (n + 1) >> 1;
		if (i & 1) {
			swap(a, b);
		}
		while (a--) {
			cout << l << " ";
			l++;
		}
		while (b--) {
			cout << r << " ";
			r--;
		}
		cout << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(),c.end()
#define rep(i,a,n) for(long long i=a;i<=n;i++)
typedef long long ll;
typedef long double ld;

#define NDEBUG
#ifdef NDEBUG
#define debug(...)
#else
#include"debug.cpp"
#endif

const int N=2e5+5;
long long test, n, m, k,x ,y,t ,q,z,d,ans ,a[305][305],b[N];
string s;
void solve(){
	cin >> n;
	ll r=n*n;
	for(int j=n;j>=1;j--){
		if((n-j+1)%2) k=1,t=1;
		else k=n,t=-1;
		for(int i=k; i>=1 && i<=n; i+=t){
			a[i][j]=r--;
		}
	}
	rep(i,1,n){
		rep(j,1,n) cout<<a[i][j]<<" "; cout<<"\n";
	}
}

int main(){ //freopen("input.txt","r",stdin);

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//cin >> test;
	//while(test--)
	solve();

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define sz(c) (ll)(c.size())
#define all(c) c.begin(),c.end()
#define rep(i,a,n) for(long long i=a;i<=n;i++)
typedef long long ll;

#define NDEBUG
#ifdef  NDEBUG
#define dbg(...)
#else
#include"debug.cpp"
#endif

const int N=2e5+10;
long long T, n, m, k, x, y, z, l, r, q, ans, b[N], c[N], mod = 1e9+7, a[N];
string s;

void solve(){
	cin >> n ;
	rep(i,1,n){
		rep(j,1,n){
			cout << ( j%2 ? n*(j-1)+i : n*j-i+1 ) << " ";
		}
		cout << "\n";
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//cin >> T; while(T--)
	solve();
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(),c.end()
#define rep(i,a,n) for(long long i=a;i<=n;i++)
typedef long long ll;
typedef long double ld;

#define NDEBUG
#ifdef NDEBUG
#define debug(...)
#else
#include"debug.cpp"
#endif

const int N=2e5+5;
long long test, n, m, k,x ,y ,q,z,d,ans ,a[N],b[N];
string s;
void solve(){
	cin >> n;
	ll l=1,r=n*n;
	rep(i,1,n){
		cout<<l<<" "<<l+1<<" "<<r--<<"\n";
		l+=2;
	}
}

int main(){ //freopen("input.txt","r",stdin);

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//cin >> test;
	//while(test--)
	solve();

}


#include <bits/stdc++.h>
using namespace std;
int x,y,z,m,n,i,j,k,c,cnt;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    x=n*n;
    int a[n+5][n+5];
    for(j=0;j<n;j++){
        for(i=0;i<n;i++){
            c++;
            a[i][j]=c;
        }
    }
    for(j=1;j<n-1;j++){
        for(i=0;i<n/2;i++){
            swap(a[i][j],a[n-i-1][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            cout<<a[i][j]<<" ";
        }
        cout<<"\n";
    }
}


#include<iostream>
using namespace std;
int main()
{
    int n;int f=0;
    cin>>n;
    int a[n][n]={0};
    int low=1,high=n*n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(f)
            a[i][j]=low++;
            else
            a[i][j]=high--;
            f=1-f;
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
}


#include<iostream>
using namespace std;
int main()
{
    int n;int f=0;
    cin>>n;
    int a[n][n]={0};
    int low=1,high=n*n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(f)
            a[i][j]=low++;
            else
            a[i][j]=high--;
            f=1-f;
            cout<<a[i][j];
        }
        cout<<endl;
    }
}


#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cout<<n*i+j;
        }
        cout<<endl;
    }
}


#include<iostream>
using namespace std;
int main()
{
    int n;int low=1,f=1;
    cin>>n;
    int a[n][n]={0};
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(f)
            a[j][i]=low++;
            else
            a[n-1-j][i]=low++;
        }
        f=1-f;
    }
     for(int i=0;i<n;i++)
     {
        for(int j=0;j<n;j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
     }
}


#include<bits/stdc++.h>

using namespace std;

struct classcomp {
  bool operator() (const int& lhs, const int& rhs) const
  {return lhs<rhs;}
};

int main() {
    int n,a,b,c,x,t;
    cin>>n;
    int cnt=0, it1=1;
    int v[n][n];
    bool flg=0;

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

	    	if(i==(n/2)){
	    		for (int j = 0; j < n; ++j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    	else if((i>(n/2) && (i%2 == 0)) || (i<(n/2) && (i%2 == 1))){
		    	for (int j = 0; j < n; ++j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    	else{
	    		for (int j = n-1; j>=0; --j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    }

	}

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

    return 0;
}

// 2 8 5
// 9 3 4
// 7 6 1


#include<bits/stdc++.h>

using namespace std;

struct classcomp {
  bool operator() (const int& lhs, const int& rhs) const
  {return lhs<rhs;}
};

int main() {
    int n,a,b,c,x,t;
    cin>>n;
    int cnt=0, it1=1;
    int v[n][n];
    bool flg=0;

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

	    	if(i==(n/2)){
	    		for (int j = 0; j < n; ++j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    	else if((i>(n/2) && (i%2 == 0)) || (i<(n/2) && (i%2 == 1))){
		    	for (int j = 0; j < n; ++j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    	else{
	    		for (int j = n-1; j>=0; --j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    }

	}

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

    return 0;
}

// 2 8 5
// 9 3 4
// 7 6 1


#include<bits/stdc++.h>

using namespace std;

struct classcomp {
  bool operator() (const int& lhs, const int& rhs) const
  {return lhs<rhs;}
};

int main() {
    int n,a,b,c,x,t;
    cin>>n;
    int cnt=0, it1=1;
    int v[n][n];
    bool flg=0;

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

	    	if(i==(n/2)){
	    		for (int j = 0; j < n; ++j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    	else if((i>(n/2) && (i%2 == 0)) || (i<(n/2) && (i%2 == 1))){
		    	for (int j = 0; j < n; ++j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    	else{
	    		for (int j = n-1; j>=0; --j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    }

	}

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

    return 0;
}

// 2 8 5
// 9 3 4
// 7 6 1


#include<bits/stdc++.h>

using namespace std;

struct classcomp {
  bool operator() (const int& lhs, const int& rhs) const
  {return lhs<rhs;}
};

int main() {
    int n,a,b,c,x,t;
    cin>>n;
    int cnt=0, it1=1;
    int v[n][n];
    bool flg=0;

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

	    	if(i==(n/2)){
	    		for (int j = 0; j < n; ++j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    	else if((i>(n/2) && (i%2 == 0)) || (i<(n/2) && (i%2 == 1))){
		    	for (int j = 0; j < n; ++j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    	else{
	    		for (int j = n-1; j>=0; --j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    }

	}

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

    return 0;
}

// 2 8 5
// 9 3 4
// 7 6 1


#include<bits/stdc++.h>

using namespace std;

struct classcomp {
  bool operator() (const int& lhs, const int& rhs) const
  {return lhs<rhs;}
};

int main() {
    int n,a,b,c,x,t;
    cin>>n;
    int cnt=0, it1=1;
    int v[n][n];
    bool flg=0;

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

	    	if(i==(n/2)){
	    		for (int j = 0; j < n; ++j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    	else if((i>(n/2) && (i%2 == 0)) || (i<(n/2) && (i%2 == 1))){
		    	for (int j = 0; j < n; ++j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    	else{
	    		for (int j = n-1; j>=0; --j)
			    {
			    	v[i][j] = it1++;
			    }
	    	}
	    }

	}

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

    return 0;
}

// 2 8 5
// 9 3 4
// 7 6 1


#include <iostream>
#include <limits>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <iomanip>      // std::setprecision
using namespace std;
typedef long long int l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define deb(x) cout << #x << ": " << x << endl
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<"\n";
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
const int MOD = 1e9+7;

int main()
{
    FIO;
    int t;
    t = 1;
    // cin>>t;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    for(int tc=0;tc<t;tc++)
    {
        int n;
        cin>>n;
        int arr[n+1][n+1];
        int p=0;
        for(int j=1;j<=n;j++)
        {
            if(j%2==1)
            {
                int cnt = p+1;
                for(int i=1;i<=n;i++,cnt++) arr[i][j] = cnt;
                p +=n;
            }
            else
            {
                int cnt = 2*p;
                for(int i=1;i<=n;i++,cnt--) arr[i][j] = cnt;
                p = 2*p;
            }
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++) cout<<arr[i][j]<<" ";
            cout<<"\n";
        }
    }
    return 0;
}


#include <iostream>
#include <limits>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <iomanip>      // std::setprecision
using namespace std;
typedef long long int l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define deb(x) cout << #x << ": " << x << endl
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<"\n";
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
const int MOD = 1e9+7;

int main()
{
    FIO;
    int t;
    t = 1;
    // cin>>t;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    for(int tc=0;tc<t;tc++)
    {
        int n;
        cin>>n;
        lu1 arr[n+1][n+1];
        int p=0;
        for(int j=1;j<=n;j++)
        {
            if(j%2==1)
            {
                lu1 cnt = p+1;
                for(int i=1;i<=n;i++,cnt++) arr[i][j] = cnt;
                p +=n;
            }
            else
            {
                lu1 cnt = p+n;
                for(int i=1;i<=n;i++,cnt--) arr[i][j] = cnt;
                p += n;
            }
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++) cout<<arr[i][j]<<" ";
            cout<<"\n";
        }
    }
    return 0;
}


#include <iostream>
#include <limits>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <iomanip>      // std::setprecision
using namespace std;
typedef long long int l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define deb(x) cout << #x << ": " << x << endl
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<"\n";
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
const int MOD = 1e9+7;

int main()
{
    FIO;
    int t;
    t = 1;
    // cin>>t;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    for(int tc=0;tc<t;tc++)
    {
        int n;
        cin>>n;
        l1 arr[n+1][n+1];
        int p=0;
        for(int j=1;j<=n;j++)
        {
            if(j%2==1)
            {
                l1 cnt = p+1;
                for(int i=1;i<=n;i++,cnt++) arr[i][j] = cnt;
                p +=n;
            }
            else
            {
                l1 cnt = 2*p;
                for(int i=1;i<=n;i++,cnt--) arr[i][j] = cnt;
                p = 2*p;
            }
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++) cout<<arr[i][j]<<" ";
            cout<<"\n";
        }
    }
    return 0;
}


#include <cstdio>

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    if (i & 1)
      for (int j = (i - 1) * n + 1; j <= i * n; ++j)
        printf("%d ", j);
    else
      for (int j = i * n; j >= (i - 1) * n + 1; --j)
        printf("%d ", j);
    printf("\n");
  }
  return 0;
}


#include <cstdio>

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    if (i & 1)
      for (int j = i; j <= i + n - 1; ++j)
        printf("%d ", j);
    else
      for (int j = i + n - 1; j >= i; --j)
        printf("%d ", j);
    printf("\n");
  }
  return 0;
}


#include <iostream>
using namespace std;

int n, k;
int map[301][301];

int main()
{
	cin >> n;
	for (int i=0; i<n; ++i) {
		for (int j=0; j<n; ++j) {
			map[i][j] = ++k;
		}
	}

	for (int i=0; i<n; i++) {
		for (int j=n-1; j>=0; j--) {
			cout << map[j][i] << ' ';
		}
		cout << '\n';
	}

	return 0;
}


#include <iostream>
using namespace std;

int n, k;
int map[301][301];

int main()
{
	cin >> n;
	for (int i=0; i<n; ++i) {
		if (i % 2) {
			for (int j=0; j<n; ++j)
				map[i][j] = ++k;
		} else {
			for (int j=n-1; j>=0; j--)
				map[i][j] = ++k;
		}
	}

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

	return 0;
}


#include <iostream>
using namespace std;

int n, k;
int map[301][301];

int main()
{
	cin >> n;
	for (int i=0; i<n; ++i) {
		for (int j=0; j<n; ++j) {
			map[i][j] = ++k;
		}
	}

	for (int i=n-1; i>=0; i--) {
		for (int j=n-1; j>=0; j--) {
			cout << map[j][i] << ' ';
		}
		cout << '\n';
	}

	return 0;
}


#include <iostream>
using namespace std;

int n, k;
int map[301][301];

int main()
{
	cin >> n;
	for (int i=0; i<n; ++i) {
		if (i % 2) {
			for (int j=n-1; j>=0; j--)
				map[j][i] = ++k;
		} else {
			for (int j=0; j<n; ++j)
				map[j][i] = ++k;
		}
	}

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

	return 0;
}


#include <iostream>
using namespace std;

int t, a, b, c;

int main()
{
	cin >> t;
	while (t--) {
		cin >> a >> b >> c;
		int ans = 0;

		int x = min(b, c/2);
		b -= x;
		int y = min(a, b/2);

		cout << (x + y) * 3 << '\n';
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair <int,int>
#define pll pair <ll,ll>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define ull unsigned long long
#define pdd pair <double,double>
#define pb push_back
#define mp make_pair
#define puu pair<ull,ull>
#define pvv pair<vector<int>, vector<int> >
#define _bp __builtin_popcount
#define ptt pair <Tree*,Tree*>
#define all(v) v.begin(),v.end()
#define en "\n"
//const long double pi = acos(-1);
void boos()
{
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}
void file()
{
   freopen("robot.in","r",stdin);
   freopen("robot.out","w",stdout);
}
const ll INF = (ll)1e9 + 7ll;
const ll INF1 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTmx = (int)1e9;
const ld EPS = (ld)1e-9;
const int N = 3e5 + 100;
vector <int> g[N];
int main()
{
    //file();
    boos();
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
    	int tek = 0;
    	for(int j = i;j <= n + i - 1;j++)
    	{
    		int dd = j;
    		if(dd > n)dd -= n;
    		cout << tek + dd << " ";
    		tek += n;
		}
		cout << en;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair <int,int>
#define pll pair <ll,ll>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define ull unsigned long long
#define pdd pair <double,double>
#define pb push_back
#define mp make_pair
#define puu pair<ull,ull>
#define pvv pair<vector<int>, vector<int> >
#define _bp __builtin_popcount
#define ptt pair <Tree*,Tree*>
#define all(v) v.begin(),v.end()
#define en "\n"
//const long double pi = acos(-1);
void boos()
{
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}
void file()
{
   freopen("robot.in","r",stdin);
   freopen("robot.out","w",stdout);
}
const ll INF = (ll)1e9 + 7ll;
const ll INF1 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTmx = (int)1e9;
const ld EPS = (ld)1e-9;
const int N = 3e5 + 100;
vector <int> g[N];
int was[N][N];
int main()
{
    //file();
    boos();
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
    	int tek = 0;
    	for(int j = i;j <= n + i - 1;j++)
    	{
    		int dd = j;
    		if(dd > n)dd -= n;
    		cout << tek + dd << " ";
    		tek += n;
		}
		cout << en;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair <int,int>
#define pll pair <ll,ll>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define ull unsigned long long
#define pdd pair <double,double>
#define pb push_back
#define mp make_pair
#define puu pair<ull,ull>
#define pvv pair<vector<int>, vector<int> >
#define _bp __builtin_popcount
#define ptt pair <Tree*,Tree*>
#define all(v) v.begin(),v.end()
#define en "\n"
//const long double pi = acos(-1);
void boos()
{
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}
void file()
{
   freopen("robot.in","r",stdin);
   freopen("robot.out","w",stdout);
}
const ll INF = (ll)1e9 + 7ll;
const ll INF1 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTmx = (int)1e9;
const ld EPS = (ld)1e-9;
const int N = 3e5 + 100;
vector <int> g[N];
int main()
{
    //file();
    boos();
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
    	int tek = 0;
    	for(int j = 1;j <= n / 2 + n % 2;j++)
    	{
    		cout << tek + i << " ";
    		tek += n;
		}
		for(int j = n / 2 + n % 2 + 1;j <= n;j++)
		{
			cout << tek + n - i + 1 << " ";
			tek += n;
		}
		cout << en;
	}
}


    #include <bits/stdc++.h>

    #define endl "\n"
    #define ll long long int

    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        cin>>T;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n;
            cin>>n;
            ll arr[n][n];
            ll sum=n*n;

            ll i=0,j=0;

            for(i=0;i<n;i++)
            {
                for (j = 0; j < n;j++)
                  {
                      arr[i][j]=sum--;
                  }

            }

            for (i = 1; i <=n-2;i++)
            {
                sort((*(arr+i)+0),(*(arr+i)+n));
            }

            for (i = n-1; i >=0; i--)
            {
                for (j= n-1; j>=0; j--)
                {1
                    cout<<arr[j][i]<<" ";
                }
                cout<<endl;
            }

        }

        return 0;
}


    #include <bits/stdc++.h>

    #define endl "\n"
    #define ll long long int

    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);

            ll n;
            cin>>n;
            ll arr[n][n];
            ll sum=n*n;

            ll i=0,j=0;

            for(i=0;i<n;i++)
            {
                for (j = 0; j < n;j++)
                  {
                      arr[i][j]=sum--;
                  }

            }

            for (i = 1; i <=n-2;i++)
            {
                sort((*(arr+i)+0),(*(arr+i)+n));
            }

            for (i = n-1; i >=0; i--)
            {
                for (j= n-1; j>=0; j--)
                {
                    cout<<arr[j][i]<<" ";
                }
                cout<<endl;
            }

        return 0;
}


    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second

    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        cin>>T;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n;
            cin>>n;
            ll sum=0;
            ll arr[n][n];
            ll i=0,j=0;

            for(i=0;i<n;i++)
            {
                for (j = 0; j < n;j++)
                  {
                      arr[i][j]=++sum;
                  }

            }

            for (int j = 1; j <= n-2; j++)
            {
                sort(arr[0][j],arr[0][n]);
            }

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

        return 0;
        }
    }


    #include <bits/stdc++.h>

    #define endl "\n"
    #define ll long long int

    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        cin>>T;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n;
            cin>>n;
            ll arr[n][n];
            ll sum=n*n;

            ll i=0,j=0;

            for(i=0;i<n;i++)
            {
                for (j = 0; j < n;j++)
                  {
                      arr[i][j]=sum--;
                  }

            }

            for (i = 1; i <=n-2;i++)
            {
                sort((*(arr+i)+0),(*(arr+i)+n));
            }

            for (i = n-1; i >=0; i--)
            {
                if(i>1 && i<=n-2)
                sort((*(arr+i)+0),(*(arr+i)+n));

                for (j= n-1; j>=0; j--)
                {
                    cout<<arr[j][i]<<" ";
                }
                cout<<endl;
            }

        }

        return 0;
}


    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second

    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        cin>>T;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n;
            cin>>n;
            ll sum=0;
            ll arr[n][n];
            ll i=0,j=0;

            for(i=0;i<n;i++)
            {
                for (j = 0; j < n;j++)
                  {
                      arr[i][j]=++sum;
                  }

            }

            for ( j = 1; j <= n-2; j++)
            {
                sort(arr[0][j],arr[0][n]);
            }

            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;
int a[305][305];
int main(){
	int n;
	scanf("%d",&n);
	int tx=1,ty=1,cnt=n*n;
	while(cnt){
		a[tx][ty]=cnt--;
		if(ty&1){
			if(tx<n)tx++;
			else ty++;
		}
		else{
			if(tx>1)tx--;
			else ty++;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)printf("%d ",a[i][j]);
		printf("\n");
	}
}


    #include <bits/stdc++.h>

    #define endl "\n"
    #define ll long long int

    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        cin>>T;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n;
            cin>>n;
            ll arr[n][n];
            ll sum=n*n;

            ll i=0,j=0;

            for(i=0;i<n;i++)
            {
                for (j = 0; j < n;j++)
                  {
                      arr[i][j]=sum--;
                  }

            }

            for (i = 1; i <=n-2;i++)
            {
                sort((*(arr+i)+0),(*(arr+i)+n));
            }

            for (i = n-1; i >=0; i--)
            {
                for (j= n-1; j>=0; j--)
                {
                    cout<<arr[j][i]<<" ";
                }
                cout<<endl;
            }

        }

        return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 101;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ld PI = 4 * atan((ld) 1);

int main() {
    fast_io;
    set_random;
    ll n;
    cin >> n;
    for (ll i = 0 ; i < n * n ; i += n)
    {
        for (ll j = i ; j < i + n ; j++)
        {
            cout << j + 1 << " ";
        }
        cout << endl;
    }
    return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 400;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ld PI = 4 * atan((ld) 1);
ll a[MAXA][MAXA];

int main() {
    fast_io;
    set_random;
    ll n;
    cin >> n;
    ll tmp = 0;
    for (int i = 0; i < n; i += 2) {
        for (ll j = 0; j < n; j++) {
            a[j][i] = ++tmp;
        }
        tmp += n;
    }
    ll bib = n + n;
    for (ll i = 1; i < n; i += 2) {
        for (ll j = 0; j < n; j++) {
            a[j][i] = bib--;
        }
        bib += 2 * n;
    }
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 101;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ld PI = 4 * atan((ld) 1);

int main() {
    fast_io;
    set_random;
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            cout << j * n +i+ 1 << sep;
        }
        cout << endl;
    }
    return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 400;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ld PI = 4 * atan((ld) 1);
ll a[MAXA][MAXA];

int main() {
    fast_io;
    set_random;
    ll n;
    cin >> n;
    ll tmp = 0;
    for (int i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            a[j][i] = ++tmp;
        }
    }
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++)
        {
            cout << a[i][j] << sep;
        }
        cout << endl;
    }
    return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 400;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ld PI = 4 * atan((ld) 1);
ll a[MAXA][MAXA];

int main() {
    fast_io;
    set_random;
    ll n;
    cin >> n;
    ll tmp = 0;
    for (int i = 0; i < n; i += 2) {
        for (ll j = 0; j < n; j++) {
            a[j][i] = ++tmp;
        }
        tmp += n;
    }
    ll bib = n + n;
    for (ll i = 1; i < n; i += 2) {
        for (ll j = 0; j < n; j++) {
            a[j][i] = bib--;
        }
        bib += (n - 1) * n;
    }
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 400;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ld PI = 4 * atan((ld) 1);
ll a[MAXA][MAXA];

int main() {
    fast_io;
    set_random;
    ll n;
    cin >> n;
    ll tmp = 0;
    for (int i = 0; i < n; i += 2) {
        for (ll j = 0; j < n; j++) {
            a[j][i] = ++tmp;
        }
        tmp += n;
    }
    ll bib = n + n;
    for (ll i = 1; i < n; i += 2) {
        for (ll j = 0; j < n; j++) {
            a[j][i] = bib--;
        }
        bib = a[n - 1][i + 1] + n;
    }
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < n; j++) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#define arrtrace(N, M, m) puts(""); for (int z = 0; z < N; z++) { for (int x = 0; x < M; x++) { printf("%2lld ", m[z][x]); }puts(""); }
#define range(a) a.begin(), a.end()
#define int long long
#define INF 100007
#define ld long double
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << ": " << arg1 << " |";
	__f(comma + 1, args...);
}
/*--------------------------------------------------------------*/
int N;
int m[301][301];

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin >> N;
	int cnt = 1;
	int i = 0, j = 0;
	for (j = 0; j < N; j++)
	{
		if(i % 2 == 0)
		for (i = N-1; i >= 0; i--)
		{
			//int si = (j + i) % N;
			m[i][j] = cnt++;
		}
		else
			for (i = 0; i < N ; i++)
			{
				//int si = (j + i) % N;
				m[i][j] = cnt++;
			}

	}
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if(j != N-1)
				cout << m[i][j] << " ";
			else
				cout << m[i][j];
		}
		cout << '\n';
	}
	cout << '\n';
	return 0;
}


#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#define arrtrace(N, M, m) puts(""); for (int z = 0; z < N; z++) { for (int x = 0; x < M; x++) { printf("%2lld ", m[z][x]); }puts(""); }
#define range(a) a.begin(), a.end()
#define int long long
#define INF 100007
#define ld long double
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << ": " << arg1 << " |";
	__f(comma + 1, args...);
}
/*--------------------------------------------------------------*/
int N;
int m[301][301];

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin >> N;
	int cnt = 1;
	int ecnt = N * N;
	int i = 0, j = 0;
	if (N % 2 == 0)
		for (i = 0; i < N; i++)
		{
			for (j = 0; j < N; j++)
			{
				if (j >= N / 2) m[i][j] = ecnt--;
				else m[i][j] = cnt++;
			}
		}
	else if (N % 2 == 1) {
		for (j = 0; j < N; j++)
		{
			if(j % 2 == 0)
				for (i = 0; i < N; i++)
				{
					m[i][j] = cnt++;
				}
			else
				for (i = N-1; i >= 0; i--)
				{
					m[i][j] = cnt++;
				}
		}
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (j != N - 1)
				cout << m[i][j] << " ";
			else
				cout << m[i][j];
		}
		cout << '\n';
	}
	cout << '\n';
	return 0;
}