      PROGRAM CGDATA
c     GENEROWANIE MACIERZY a, WEKTORA b I WEKTORA XX
      implicit none 
      integer N,pyt

    1 write(*,*)'PROGRAM CGDATA'
      write(*,*)'PODAJ N'
      read (*,*) N
      
      call SUBMAIN(N)
      
      write(*,*)'GOTOWE'
      write(*,*)' 0 - KONIEC'
      write(*,*)' 1 - OD POCZATKU'
      read (*,*) pyt
      if(pyt.eq.0)then
      goto 100
      else
      goto 1
      endif
  100 stop 100
      end
      
      subroutine SUBMAIN(N)
      implicit none
      real*8 a,b,x,XX,V,h,E,O
      integer i,j,k,l,N
      dimension a(N,N),V(N,N),b(N),x(N),XX(N)
      
c     STALE
      O=real(0)
      E=real(1)
      h=E/N
      
      do 1,j=1,N,1
      XX(j)=h*j
    1 continue
    
c     a
      do 2,l=1,N,1
      do 3,i=1,N,1
      a(l,i)=O
      do 4,k=1,N,1
      V(l,k)=XX(k)**(l-1)
      V(i,k)=XX(k)**(i-1)
      a(l,i)=a(l,i)+V(l,k)*V(i,k)
    4 continue
    3 continue
    2 continue
    
c     b
      do 5,l=1,N,1
      b(l)=O
      do 6,i=1,N,1
      b(l)=b(l)+a(l,i)
    6 continue
    5 continue

c     OUTPUT
c     a
      open(unit=20,file='a')
      rewind(20)
      do 7,l=1,N,1
      do 8,i=1,N,1
      write(20,*) a(l,i)
    8 continue
    7 continue
      close(20)
c     b
      open(unit=21,file='b')
      rewind(21)
      do 9,l=1,N,1
      write(21,*) b(l)
    9 continue
      close(21)
      
c     x
      open(unit=22,file='x')
      rewind(22)
      do 10,j=1,N,1
      write(22,*) XX(j)
   10 continue
   
      close(20)
      close(21)
      close(22)
      
      return
      end
      
      