#include <iostream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>

typedef std::pair<int, int> Position;
typedef std::vector<Position> Positions;

namespace {

  bool safe (int x, int y, Positions const & positions) {
    for (Positions::const_iterator iter = positions.begin(); iter != positions.end(); ++iter) {
      int x1 = iter->first, y1 = iter->second;
      if (x == x1 || y == y1 || y - x == y1 - x1 || y + x == y1 + x1) {
        return false;
      }
    }
    return true;
  }  

  class Conflict {};

  Positions & queens(int const n, int x, int y, Positions & positions) {
    if (x > n) {
      return positions;
    } else if (y > n) { 
      throw Conflict();
    } else {
      if (safe(x, y, positions)) {
        positions.push_back(std::make_pair(x, y));
        try {
          return queens(n, x+1, 1, positions);
        } catch (Conflict c) {
          positions.pop_back();
        }
      }
      return queens(n, x, y+1, positions);
    }
  }
}


int main(int argc, char ** argv) {
  std::istringstream parser(argv[1]);
  int n;
  parser >> n;
  
  Positions p;

  p = queens(n, 1, 1, p);

  for (Positions::const_iterator iter = p.begin(); iter != p.end(); ++iter) {
    std::cout << iter->first << ", " << iter->second << std::endl;
  }

  return 0;
}

