#include <string.h>
#include <stdio.h>

/* triple-single functions adapted from ENS of Lyon's CRlibm, 
   http://l...content-available-to-author-only...n.fr/projects/crlibm */

void Add12(float *s, float *r, float a, float b)          
{
  float _z, _a=a, _b=b;    
  *s = _a + _b;              
  _z = *s - _a;              
  *r = _b - _z;   
}

void Add22(float *zh, float *zl, float xh, float xl, float yh, float yl)  
{
  float _r,_s;                            
  _r = (xh)+(yh);                          
  _s = ((((xh)-_r) +(yh)) + (yl)) + (xl);  
  *zh = _r+_s;                             
  *zl = (_r - (*zh)) + _s;    
}

#define ABS(x) (((x)>0) ? (x) : (-(x)))

void Sub22Cond(float *zh, float *zl, float xh, float xl, float yh, float yl)  
{
  float _r,_s;
  _r = (xh)+(-yh);
  _s = ((ABS(xh)) > (ABS(yh)))? 
       ((xh)-_r+(-yh)+(-yl)+(xl)) : ((-yh)-_r+(xh)+(xl)+(-yl));
  *zh = _r+_s;
  *zl = (_r - (*zh)) + _s;
}

void Add12Cond(float *s, float *r, float a, float b)
{
  float _z, _a=a, _b=b;
  *s = _a + _b;
  if (ABS(a) > ABS(b)){            
    _z = *s - _a;                   
    *r = _b - _z;                   
  }else {                          
    _z = *s - _b;                   
    *r = _a - _z;}
}   

void Mul12(float *rh, float *rl, float u, float v)                        
{                                               
  const float c  = 4097.0f; /* 1<<12 + 1 */   
  float up, u1, u2, vp, v1, v2;                
  float _u=u, _v=v;                            
  up = _u*c;        vp = _v*c;                  
  u1 = (_u-up)+up;  v1 = (_v-vp)+vp;            
  u2 = _u-u1;       v2 = _v-v1;                 
                                                
  *rh = _u*_v;                                  
  *rl = (((u1*v1-*rh)+(u1*v2))+(u2*v1))+(u2*v2);
}


void Mul23(float *resh, float *resm, float *resl, 
           float ah, float al, float bh, float bl)                
{                                                              
    float _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10;  
                                                               
    Mul12((resh),&_t1,(ah),(bh));                              
    Mul12(&_t2,&_t3,(ah),(bl));                                
    Mul12(&_t4,&_t5,(al),(bh));                                
    _t6 = (al) * (bl);                                         
    Add22(&_t7,&_t8,_t2,_t3,_t4,_t5);                      
    Add12(&_t9,&_t10,_t1,_t6);                                   
    Add22((resm),(resl),_t7,_t8,_t9,_t10);                 
}

void Add33Cond(float *resh, float *resm, float *resl,
               float ah, float am, float al, float bh, float bm, float bl)      
{                                                            
    float _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8;           
                                                             
    Add12Cond(resh,&_t1,(ah),(bh));                          
    Add12Cond(&_t2,&_t3,(am),(bm));                            
    _t6 = (al) + (bl);                                       
    Add12Cond(&_t7,&_t4,_t1,_t2);                              
    _t5 = _t3 + _t4;                                         
    _t8 = _t5 + _t6;                                         
    Add12Cond(resm,resl,_t7,_t8);                  
}

void DoRenormalize3(float *resh, float *resm, float *resl, 
                    float ah, float am, float al)     
{                                                      
    float _t1h, _t1l, _t2l;                           
                                                       
    Add12(&_t1h, &_t1l, (am), (al));                     
    Add12(resh, &_t2l, (ah), (_t1h));              
    Add12(resm, resl, _t2l, _t1l);           
}

/* Parse an integer into a double-single. */
void parse(float *h, float *l, const char *s)
{
  float acc = 0;

  for ( ; ; )
    {
      acc = 10.0f * acc + (*s - '0');

      s++;

      if (*s == 0) 
        {
          *h = acc;
          *l = 0;
          break;
        }

      /* test acc rather than s; Regehr is the sort of
         person to test long suites of leading zeroes: */
      if (acc >= 100000.0f)
        {
          float acc2 = 0;
          float factor = 1;
          for ( ; ; )
            {
              /* XXX I'll bet this can be simplified by computing
                 acc *= 10.0f; instead of factor *= 10.0f; and a simple
                 Add12 of acc and acc2 at the end, for the right threshold
                 instead of 100000. */
              factor *= 10.0f;
              acc2 = 10.0f * acc2 + (*s - '0');
              s++;
              if (*s == 0) break;
            }
          Mul12(h, l, acc, factor);
          Add22(h, l, *h, *l, acc2, 0);
          break;
        } 
    }
}

int main(int c, char **v)
{
  if (c != 7)
    {
      printf("Usage!\n");
      return 1;
    }
  float xh1, xl1, yh1, yl1, xh2, xl2, yh2, yl2, xh3, xl3, yh3, yl3;
  parse(&xh1, &xl1, v[1]);
  parse(&yh1, &yl1, v[2]);
  parse(&xh2, &xl2, v[3]);
  parse(&yh2, &yl2, v[4]);
  parse(&xh3, &xl3, v[5]);
  parse(&yh3, &yl3, v[6]);

  float dxh1, dxl1, dyh1, dyl1, dxh2, dxl2, dyh2, dyl2, dxh3, dxl3, dyh3, dyl3;

  Sub22Cond(&dxh1, &dxl1, xh1, xl1, xh2, xl2);
  Sub22Cond(&dyh1, &dyl1, yh1, yl1, yh2, yl2);
  Sub22Cond(&dxh2, &dxl2, xh2, xl2, xh3, xl3);
  Sub22Cond(&dyh2, &dyl2, yh2, yl2, yh3, yl3);
  Sub22Cond(&dxh3, &dxl3, xh3, xl3, xh1, xl1);
  Sub22Cond(&dyh3, &dyl3, yh3, yl3, yh1, yl1);

  float sdxh1, sdxm1, sdxl1, sdyh1, sdym1, sdyl1;
  float sdxh2, sdxm2, sdxl2, sdyh2, sdym2, sdyl2;
  float sdxh3, sdxm3, sdxl3, sdyh3, sdym3, sdyl3;

  // Are vectors colinear? Use cross-product v1x*v2y == v2x*v1y 

  Mul23(&sdxh1, &sdxm1, &sdxl1, dxh1, dxl1, dyh2, dyl2);
  Mul23(&sdxh2, &sdxm2, &sdxl2, dxh2, dxl2, dyh1, dyl1);
  DoRenormalize3(&sdxh1, &sdxm1, &sdxl1, sdxh1, sdxm1, sdxl1);
  DoRenormalize3(&sdxh2, &sdxm2, &sdxl2, sdxh2, sdxm2, sdxl2);
  
  /* XXX Compare. Products may be acurate to 2^-68 or so
     if we interpolate from CRlibm's error computations for
     double. We need 2^62. Can we compare for exact equality
     or do we need to COMPARE UP TO EPSILON? */

  // Now reuse the six triple-singles to compute squares of lengths of sides

  Mul23(&sdxh1, &sdxm1, &sdxl1, dxh1, dxl1, dxh1, dxl1);
  Mul23(&sdyh1, &sdym1, &sdyl1, dyh1, dyl1, dyh1, dyl1);
  Mul23(&sdxh2, &sdxm2, &sdxl2, dxh2, dxl2, dxh2, dxl2);
  Mul23(&sdyh2, &sdym2, &sdyl2, dyh2, dyl2, dyh2, dyl2);
  Mul23(&sdxh3, &sdxm3, &sdxl3, dxh3, dxl3, dxh3, dxl3);
  Mul23(&sdyh3, &sdym3, &sdyl3, dyh3, dyl3, dyh3, dyl3);

  DoRenormalize3(&sdxh1, &sdxm1, &sdxl1, sdxh1, sdxm1, sdxl1);
  DoRenormalize3(&sdxh2, &sdxm2, &sdxl2, sdxh2, sdxm2, sdxl2);
  DoRenormalize3(&sdxh3, &sdxm3, &sdxl3, sdxh3, sdxm3, sdxl3);
  DoRenormalize3(&sdyh1, &sdym1, &sdyl1, sdyh1, sdym1, sdyl1);
  DoRenormalize3(&sdyh2, &sdym2, &sdyl2, sdyh2, sdym2, sdyl2);
  DoRenormalize3(&sdyh3, &sdym3, &sdyl3, sdyh3, sdym3, sdyl3);

  Add33Cond(&sdxh1, &sdxm1, &sdxl1, sdxh1, sdxm1, sdxl1, sdyh1, sdym1, sdyl1);
  Add33Cond(&sdxh2, &sdxm2, &sdxl2, sdxh2, sdxm2, sdxl2, sdyh2, sdym2, sdyl2);
  Add33Cond(&sdxh3, &sdxm3, &sdxl3, sdxh3, sdxm3, sdxl3, sdyh3, sdym3, sdyl3);

  DoRenormalize3(&sdxh1, &sdxm1, &sdxl1, sdxh1, sdxm1, sdxl1);
  DoRenormalize3(&sdxh2, &sdxm2, &sdxl2, sdxh2, sdxm2, sdxl2);
  DoRenormalize3(&sdxh3, &sdxm3, &sdxl3, sdxh3, sdxm3, sdxl3);

  // We have the squares of the lengths of each side, test them for equality:

  float n = 0.0f;
  
  if (sdxh1 == sdxh2 && sdxm1 == sdxm2 && sdxl1 == sdxl2)
    // See XXX above.
    n = 1.0f;

  if (sdxh1 == sdxh3 && sdxm1 == sdxm3 && sdxl1 == sdxl3)
    n++;

  if (sdxh2 == sdxh3 && sdxm2 == sdxm3 && sdxl2 == sdxl3)
    n++;
 
  if (n == 1.0f) printf("isosceles");
  else if (n == 3.0f) printf("equilateral");
  else printf("scalene");
 
  printf(" ");

#define GT(n, p) \
  (sdxh##n > sdxh##p ||  \
      (sdxh##n == sdxh##p && (sdxm##n > sdxm##p ||  \
                          (sdxm##n == sdxm##p && sdxl##n > sdxl##p))))

  float tmp;

#define SWAP(n, p) \
  tmp = sdxh##n; sdxh##n = sdxh##p; sdxh##p = tmp; \
  tmp = sdxm##n; sdxm##n = sdxm##p; sdxm##p = tmp; \
  tmp = sdxl##n; sdxl##n = sdxl##p; sdxl##p = tmp;

  if (GT(2, 1))
    {
      SWAP(1, 2)
    }

  if (GT(3, 1))
    {
      SWAP(1, 3)
    }

  /* (sdxh1, sdxm1, sdxl1) contains the longest square of side length,
     the other two triple-singles contain the other two sides. */

  Add33Cond(&sdxh2, &sdxm2, &sdxl2, sdxh2, sdxm2, sdxl2, sdxh3, sdxm3, sdxl3);
  DoRenormalize3(&sdxh2, &sdxm2, &sdxl2, sdxh2, sdxm2, sdxl2);
   
  if (GT(2, 1))
    printf("acute");
  else if (GT(1, 2))
    printf("obtuse");
  else printf("right");

  printf("\n");
  return 0;
}
