#include <iostream>

using namespace std;

int a[101][101], b[101][101], n;

int main()
{
    int i, k, j;
    n = 3;
    k = 1;
    for (i = 1; i <= n; ++i)
        for (j = 1; j <= n; ++j)
            a[i][j] = k++;
    for (i = 1; i <= n; ++i)
    {
        for (j = 1; j <= n; ++j)
            cout << a[i][j];
        cout << "\n";
    }
    cout << "\n\n";
    for (i = 1; i <= n; ++i)
        for (j = 1; j <= n; ++j)
            b[j][i] = a[i][j];
    for (i = 1; i <= n; ++i)
    {
        for (j = 1; j <= n; ++j)
            cout << b[i][j];
        cout << "\n";
    }
    return 0;
}
