
import java.io.*;
import java.util.*;
// Position is a cursor
// Position is a two-value pair: row & column

class Position
{

    protected int row, col;	// Current position

    public Position(int r, int c)
    // pre: r & c are position (note order)
    // post: constructs position [r][c]
    {
	row = r;
	col = c;
    }

    public int col()
    // post: returns column/horizontal of position
    {
	return col;
    }

    public int row()
    // post: returns row/vertical of position
    {
	return row;
    }


    public Position north()
    // post: returns position above
    {
	return new Position(row-1,col);
    }

    public Position south()
    // post: returns position below
    {
	return new Position(row+1,col);
    }

    public Position east()
    // post: returns position to right
    {
	return new Position(row,col+1);
    }

    public Position west()
    // post: returns position to left
    {
	return new Position(row,col-1);
    }


    public boolean equals(Object other)
    // post: returns true iff objects represent same position
    {
	Position that = (Position)other;
	return ((this.row == that.row) &&
		(this.col == that.col));
    }

    public String toString()
    // post: returns string representation of Position
    {
	return "["+row+"]["+col+"]";
    }
}





