ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

[Online] ICPC Ural Regional Contest Qualifier 2026

About     Problems     Submit solution     Judge status     Standings
Contest is over

N. Rastafarians

Time limit: 0.5 second
Memory limit: 256 MB
A Rastafarian — is a peaceful, kind, and freedom-loving person whose spiritual purity is much more important than material wealth. Rastafarians value spiritual freedom, inner peace, and oppose aggression.
Vadim invented a new chess piece, which he called a Rastafarian. A Rastafarian must stand in the center of a cell; it does not move across the board, but it looks in absolutely all directions. If it sees some piece, it treats it calmly, but if it cannot see some piece (the view is blocked by another piece; in this problem you may assume that each piece is a point; the view is blocked if another figure stands on the segment between two figures), then the Rastafarian can capture it. Below are examples of cases when a Rastafarian (M) captures another piece (E), because another piece (F) blocks the view:
Problem illustration
Your task is to place exactly N Rastafarians on an N × N chessboard so that no two of them capture each other.

Input

The only line contains an integer N — the size of the chessboard (2 ≤ N ≤ 1000).

Output

Output N pairs of numbers xi and yi — the row and column of the cell where the i-th Rastafarian is placed. All cells must be pairwise distinct, and no Rastafarian can attack another Rastafarian.
It is guaranteed that a solution exists. If there are multiple solutions, output any of them.

Sample

inputoutput
4
1 1
2 3
3 2
4 4
Problem Author: Vadim Barinov
Problem Source: The 2026 ICPC Ural Qualification