#include <iostream>
#define MAX 22
#define MAX_UNI 500
using namespace std;
int main()
{
int A[MAX][MAX],B[MAX_UNI],n,m,p=0;
cin>>n>>m;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
cin>>A[i][j];
if(A[i][j]>=0)
B[p++] = A[i][j];
}
for(int i=0;i<p;i++)
cout<<B[i]<<" ";
return 0;
}