#include #include using namespace std; using namespace atcoder; using ll = long long; int N; int grid[100][100]; int main() { cin >> N; for (int i = 0; i < N; i++) { for (int j = i; j <= N + i; j++) { grid[i][j - i] = (j % N) + 1; } } for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { cout << grid[i][j] << " \n"[j == N - 1]; } } return 0; }