#include<stdio.h>
int main(){
    int m,n;
    scanf("%d %d",&n,&m);
    
    if(n=0 || n<0){
        printf("-1");
        return 0;
    }
    int matrix[m][n];
    
    for(int i = 0;i<0;i++){
        for(int j=0;i<n;j++){
            scanf("%d",&matrix[i][j]);
        }
    }
    int top = 0, bottom = n-1;
    int left = 0, right = n-1;
    while(top<=bootom && left <=right){
        for(int i = left;i<=right; i++){
        top++;
    }
    for(int i = top; i<=bottom; i++)
        printf("%d",matrix[i][right]);
        right--;
    }
    if(top <= bottom){
        for(int i = right; i>= left;i--)
            printf("%d", matrix[bottom][i]);
        bottom;
        }
        if (left <= right) {
            for (int i = bottom; i>= top; i--)
                 printf("%d",matrix[i][left]);
            left++;
        }
   }
} 
        }
        
        }
    }
        
        
    }
    
        }
    }

        
    }
}