/*
*/

#include <stdlib.h>
#include <stdio.h>
#include <values.h>
#include <math.h>

// something about vectors

#define EPS 1e-7
#define sqr(x) ((x)*(x))
#define  PI		3.14159265358979323846

void spherical(int n1, int n2)
{ double ymin,theta,dtheta,phi,dphi;
  double rad,radc;
  int    i1,i2;

  // theta and phi are sphere coordinates
  // n1 describes the number of meridians that are taken
  // n2 is computed from n1
  /* n1 = 3; */
  ymin = 1e10;
  theta = 0.0;
  dtheta = PI/2.0/(double) n1;

  printf("CMESH\n");
  printf("%d %d\n", n1+1,n2+1);

  for (i1=0;i1<=n1;i1++) // [0..Pi/2]
  {
   /*  n2 = (int) floor(4.0*n1*sin(theta)+0.5); */
    /* n2 = n1; */
    phi = 0.0;
    if (n2 !=0) dphi = 2.0*PI/(double) n2;

    for (i2=0;i2<=n2;i2++) // [0..2*Pi]
    { /* p[0][0] = theta;           p[0][1] = phi;         */
         
        rad = 1;

        printf("%lf %lf %lf  %lf %lf %lf 1\n",
                rad * cos(phi)*sin(theta),
                rad * sin(phi)*sin(theta),
                rad * cos(theta),
                0.5, 0.5, 0.5
        );
         

          phi += dphi;
    }
    printf("\n");
        theta += dtheta;
  }
}


void parab(int n1, int n2)
{ double ymin,theta,dtheta,phi,dphi;
  double rad,radc;
  int    i1,i2;

  // theta and phi are sphere coordinates
  // n1 describes the number of meridians that are taken
  // n2 is computed from n1
  /* n1 = 3; */
  ymin = 1e10;
  theta = 0.0;
  dtheta = PI/2.0/(double) n1;

  printf("CMESH\n");
  printf("%d %d\n", n1+1,n2+1);

  for (i1=0;i1<=n1;i1++) // [0..Pi/2]
  { 
   /*  n2 = (int) floor(4.0*n1*sin(theta)+0.5); */
    /* n2 = n1; */
    phi = 0.0;
    if (n2 !=0) dphi = 2.0*PI/(double) n2;

    for (i2=0;i2<=n2;i2++) // [0..2*Pi]
    { /* p[0][0] = theta;           p[0][1] = phi;         */
          
	rad = 1;
	double x = rad * cos(phi)*(theta);
	double y = rad * sin(phi)*(theta);
	double z = (x*x + y*y);

        printf("%lf %lf %lf  %lf %lf %lf 1\n", 
		x, y, z, 
		0.5, 0.5, 0.5
	); 
          
      
	  phi += dphi;
    }
    printf("\n");
	theta += dtheta;
  }


}

void main(int argc, char *argv[])

{	 
  int n1,n2;
  if ( (argc < 2) ||
       (1 != sscanf(argv[1], "%d", &n1)) )
	{printf("Needs number of points as argument\n"); exit(1);}
  n2 = n1;
  parab(n1,n2);
}

