#include<iostream>   
#include <ctime>
#include <stdlib.h>  
#include <iomanip>                          

using namespace std;

int main ()
{
int a[15][8], N, M ,i,j,c;
	srand(time(NULL));
	cout<<"N=";
	cin>>N;
	cout<<"M=";
	cin>>M;
	
	for (int i=0; i<N; i++){
         for (int j=0; j<M; j++){
	        a[i][j]=rand()%60 - 30; 
     }
}
cout<<" Randomnyi masyv"<<endl;

     for (i=0; i<N; i++) {
       for ( j = 0; j < M; j ++ ) 
      
           cout<<setw(10)<< a[i][j];         
      cout<<endl;                           
	  
}
	cout<<"vidjemni elementy"<<endl;
	 for (i=0; i<N; i++) {
       for ( j = 0; j < M; j ++ ) 
	  {
	  if (a [i][j]<0 && i%3==0 && j%3==0);
	  	  	 {

	    
		cout<< setw(10) <<a[i][j];
	  	cout<<endl;
	  }
	  
}
}
}

