#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{
    // srand(time(0));

    const unsigned trials = 100;
    unsigned solutionsFound = 0;

    for (unsigned i = 0; i < trials; ++i)
    {
        const unsigned size = 101;

        int row[size];
        int col[size];

        row[0] = 3;
        col[0] = 2;

        for (unsigned j = 1; j < size; ++j)
        {
            row[j] = row[j - 1];
            col[j] = col[j - 1];

            switch (rand() % 4)
            {
            case 0: ++row[j]; break;
            case 1: ++col[j]; break;
            case 2: --row[j]; break;
            case 3: --col[j]; break;
            }

            if (row[j] == 3 && col[j] == 9)
            {
                ++solutionsFound;

                for (unsigned k = 0; k < j + 1; ++k)
                {
                    cout << '(' << row[k] << ',' << col[k] << ") ";

                    if ((k + 1) % 12 == 0 || k == j)
                        cout << '\n';
                }
                cout << endl;
                break;
            }
        }
    }

    cout << "Escapes: " << (solutionsFound * 100.0 / trials) << "%\n";
}