/* prog2.c */
#include <stdio.h>
#include <math.h>
int main()
{
  int i;
  double x,y,s,s1,s2,s3,s4,s5,a,b;
  double sigmaa,h,sigmah,e0;
  FILE *f;
  s1=0.0;
  s2=0.0;
  s3=0.0;
  s4=0.0;
  s5=0.0;
  for(i=1;i<=6;i++)
    {
      scanf("%lf%lf%lf",&x,&y,&s);
      x=x*1.0e15;
      s1=s1+1.0/s/s;
      s2=s2+x*y/s/s;
      s3=s3+y/s/s;
      s4=s4+x/s/s;
      s5=s5+x*x/s/s;
    }
  a=(s1*s2-s3*s4)/(s1*s5-s4*s4);
  b=(s5*s3-s4*s2)/(s1*s5-s4*s4);
  f=fopen("a.dat","w");
  fprintf(f,"%e",a);
  fclose(f);
  sigmaa=sqrt(s1/(s1*s5-s4*s4));
  f=fopen("sigmaa.dat","w");
  fprintf(f,"%e",sigmaa);
  fclose(f);
  
  e0=1.60217733e-19;
  h=a*e0;
  sigmah=sigmaa*e0;
  f=fopen("h.meta","w");
  fprintf(f,"#PLOT 2\n");
  fprintf(f,"o\n");
  fprintf(f,"FHersheySans\n");
  fprintf(f,"S 100\n");
  fprintf(f,"m 1820 930\n");
  fprintf(f,"R 0\n");
  fprintf(f,"Tlb\\f2h\\f1 = (%.3f\\+-%.3f)\\md10\\sp-34\\epJs\n",
    h/1.0e-34,sigmah/1.0e-34);
  fprintf(f,"x\n");
  fclose(f);
  printf("%e %e\n",0.5,0.5e15*a+b);
  printf("%e %e\n",0.85,0.85e15*a+b);

  return 0; /* important to report success to the make command */
}
