/*********************************************
This program reads in points from a file
points.txt and writes out the lower left
and upper right endpoints of a rectangle
containing all the points read in.
**********************************************/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

/*********************************************
 ** PROTOTYPES & STRUCT DEFINITIONS
 *********************************************/
struct point
{
  double x,y;
};

double min(double a, double b);
double max(double a, double b);
point min(point a, point b);
point max(point a, point b);

/*********************************************
 ** MAIN FUNCTION
 *********************************************/
int main()
{
  // Open input file and read header information
  ifstream IN("points.txt");
  int N;
  string s;
  IN >> N >> s;

  // Read points
  point *A = new point[N];
  for(int i = 0; i < N; i++)
    IN >> A[i].x >> A[i].y;

  // Get min & max
  point m, M;
  m = M = A[0];
  for(int i = 1; i < N; i++)
  {
    m = min(m,A[i]);
    M = max(M,A[i]);
  }
  
  // Print out lower left and upper right corner of
  // bounding rectangle
  cout << "Points are contained in rectangle with\n"
       << "lower left corner (" << m.x << ',' << m.y
       << ") and\nupper right corner (" << M.x
       << ',' << M.y << ')' << endl;

  return 0;
}

/*********************************************
 ** FUNCTION DEFINITIONS
 *********************************************/
double min(double a, double b)
{
  if (b < a)
    return b;
  else
    return a;
}

double max(double a, double b)
{
  if (a < b)
    return b;
  else
    return a;
}

// returns a point whose coordinates are
// the minima of the coordinates of a and b
point min(point a, point b)
{
  point c;
  c.x = min(a.x,b.x);
  c.y = min(a.y,b.y);
  return c;
}

// returns a point whose coordinates are
// the maxima of the coordinates of a and b
point max(point a, point b)
{  
  point c;
  c.x = max(a.x,b.x);
  c.y = max(a.y,b.y);
  return c;
}