Create convert M x N matrix to 1-dimension array and output it in both row-major or column-major

Problem Description
Write a program to convert M x N matrix to 1-dimension array and output it in both row-major or column-major

M, N < 10 (Both M and N are integer)

Every elements in the matrix are integer

Input
The input data will contain multiple test cases. Each test case will contain:

M N

Matrix

Output
Row-major:

Column-major:

Sample Input
3 4
1 2 3 4
5 6 7 8
9 10 11 12
Sample Output
Row-major: 1 2 3 4 5 6 7 8 9 10 11 12
Column-major: 1 5 9 2 6 10 3 7 11 4 8 12
About
Support
Github