//#include <iostream>
#include <math.h>
using namespace std;
class Point
{
public:
			Point	()								{ X = 0; Y = 0; Z = 0;}
			Point	(double x, double y, double z)	{ X = x; Y = y; Z = z;}
	void	setX	(double x)						{ X = x; }
	void	setY	(double y)						{ Y = y; }
	void	setZ	(double z)						{ Z = z; }
	double	getX	() const						{ return X; }
	double	getY	() const						{ return Y; }
	double	getZ	() const						{ return Z; }
private:
	double X;
	double Y;
	double Z;
};
double myDistance(const Point& p1, const Point& p2)
{
	double a = 0, b = 0, c_squared = 0;
	a = p1.getX() - p2.getX();
	b = p1.getY() - p2.getY();
	c_squared = (a * a) + (b * b);
	return sqrt(c_squared);
}
double myDistance(double x1, double y1, double x2, double y2)
{
	double a = 0, b = 0, c_squared = 0;

	a = x1 - x2;
	b = y1 - y2;
	c_squared = (a * a) + (b * b);

	return sqrt(c_squared);
}
int findFacing (const Point& p1, const Point& p2)
{
	int rise = 0, run = 0;

	if		((p2.getX()  > p1.getX()) && (p2.getY() == p1.getY())) return 1;//Northeast
	else if	((p2.getX()  < p1.getX()) && (p2.getY() == p1.getY())) return 5;//Southwest
	else if ((p2.getX() == p1.getX()) && (p2.getY()  > p1.getY())) return 3;//Southeast
	else if ((p2.getX() == p1.getX()) && (p2.getY()  < p1.getY())) return 7;//Northwest
	//Quadrant II
	else if	((p2.getX() > p1.getX()) && (p2.getY() > p1.getY()))
	{
		run  = int((p2.getX() - p1.getX()));
		rise = int((p2.getY() - p1.getY()));
		if		(run  >= (2 * rise))			return 1;//Northeast
		else if (rise >= (2 * run))				return 3;//Southeast
		else									return 2;//East
	}
	//Quadrant III
	else if ((p2.getX() < p1.getX()) && (p2.getY() > p1.getY()))
	{
		run  = int((p1.getX() - p2.getX()));
		rise = int((p2.getY() - p1.getY()));
		if		(rise >= (2 * run))				return 3;//Southeast
		else if	(run  >= (2 * rise))			return 5;//Southwest
		else									return 4;//South
	}
	//Quadrant IV
	else if ((p2.getX() < p1.getX()) && (p2.getY() < p1.getY()))
	{
		run  = int((p1.getX() - p2.getX()));
		rise = int((p1.getY() - p2.getY()));
		if		(run  >= (2 * rise))			return 5;//Southwest
		else if (rise >= (2 * run))				return 7;//Northwest
		else									return 6;//West
	}
	//Quadrant I
	else
	{
		run  = int((p2.getX() - p1.getX()));
		rise = int((p1.getY() - p2.getY()));
		if		(rise >= (2 * run))				return 7;//Northwest
		else if	(run  >= (2 * rise))			return 1;//Northeast
		else									return 0;//North
	}
	return 0;
}
void getFacingAndDistance (int &FacingToTarget, int &RangeToTarget, int startX, int startY, int x, int y)
{
	double range = 0.0, newX = 0.0, newY = 0.0;
	Point One, Two;
	
	One.setX(startX); One.setY(startY);
	Two.setX(x); Two.setY(y);

	FacingToTarget	= findFacing(One, Two);
	RangeToTarget	= int(myDistance(One, Two));
}