import java.util.*;



public class queens {
    static private class IntPair {
        final int first, second;
        IntPair(int fst, int snd) {
            first = fst; second = snd;
        }
    }
    
    static private class Conflict extends Exception {}

    private static boolean safe(int x, int y, final List positions) {
        for(final Iterator iter = positions.iterator(); iter.hasNext(); ) {
            final IntPair p = (IntPair) iter.next();
            final int x1 = p.first, y1 = p.second;
            if (x == x1 || y == y1 || y - x == y1 - x1 || y + x == y1 + x1) {
                return false;
            }
        }	
        return true;
    }	 

    private static List queens(int n, int x, int y, final List positions) throws Conflict {
    	if (x > n) {
            return positions;
        } else if (y > n) { 
    	    throw new Conflict();
    	} else {
            if (safe(x, y, positions)) {
                positions.add(new IntPair(x, y));
                try {
                    return queens(n, x+1, 1, positions);
                } catch (final Conflict c) {
                    positions.remove(positions.size()-1);
                }
            }
            return queens(n, x, y+1, positions);
    	}
    }

    public static void main (String [] args) {
        int n = Integer.parseInt(args[0]);
        List arr = new ArrayList();
        
        try {
            arr = queens(n, 1, 1, arr); 
        } catch (final Conflict c) {
            System.out.println("Can't happen");
        }

        for(final Iterator iter = arr.iterator(); iter.hasNext(); ) {
            final IntPair p = (IntPair) iter.next();
            System.out.println(p.first + ", " + p.second);
        }
    }
}
