[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
mod = static integer = 1e9 + 7
define the main function
    n, m are integers, row, col are integer arrays both of size 105, table is an integer array of sizes 105 and 105, minn and flag are integers
    while read n, m
        tmp = integer = 0
        call memset with row, 0, call sizeof with row
        call memset with col, 0, call sizeof with col
        for i = 1 to n inclusive
            for j = 1 to m inclusive, read table[i][j]
        end of the block
        if m is at least n
            for i = 1 to n inclusive
                set min to 0x3f3f3f3f
                for j = 1 to m inclusive
                    if table[i][j] is less than minn, set minn to table[i][j]
                end of the block
                if minn
                    add minn to tmp
                    set row[i] to minn
                    for j = 1 to m inclusive, subtract minn from table[i][j]
                end of the block
            end of the block
            for j = 1 to m inclusive
                set minn to 0x3f3f3f3f
                for i = 1 to n inclusive
                    if table[i][j] is less than minn, set minn to table[i][j]
                end of the block
                if minn
                    add minn to tmp
                    set col[j] to minn
                    for i = 1 to n inclusive, subtract minn from table[i][j]
                end of the block
            end of the block
        else
            for j = 1 to m inclusive
                set minn to 0x3f3f3f3f
                for i = 1 to n inclusive
                    if table[i][j] is less than minn, set minn to table[i][j]
                end of the block
                if minn
                    add minn to tmp
                    set col[j] to minn
                    for i = 1 to n inclusive, subtract minn from table[i][j]
                end of the block
            end of the block
            for i = 1 to n inclusive
                set minn to 0x3f3f3f3f
                for j = 1 to m inclusive
                    if table[i][j] is less than minn, set minn to table[i][j]
                end of the block
                if minn
                    add minn to tmp
                    set row[i] to minn
                    iterate m times, subtract minn from table[i][j]
                end of the block
            end of the block
        end of the block
        set flag to 1
        for i = 1 to n inclusive
            for j = 1 to m inclusive
                if table[i][j]
                    set flag to 0
                    break
                end of the block
        if flag
            print tmp
            for i = 1 to n inclusive
                for k = 1 to row[i] inclusive, print "row ", i
            end of the block
            for j = 1 to m inclusive
                for j = 1 to col[j] inclusive, print "col ", j
            end of the block
        else
            print -1
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

static int mod = 1e9 + 7;
int main() {
    int n, m, row[105], col[105], table[105][105], minn, flag;
    while (cin >> n >> m) {
        int tmp = 0;
        memset(row, 0, sizeof(row));
        memset(col, 0, sizeof(col));
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) cin >> table[i][j];
        }
        if (m >= n) {
            for (int i = 1; i <= n; i++) {
                minn = 0x3f3f3f3f;
                for (int j = 1; j <= m; j++) {
                    if (table[i][j] < minn) minn = table[i][j];
                }
                if (minn) {
                    tmp += minn;
                    row[i] = minn;
                    for (int j = 1; j <= m; j++) table[i][j] -= minn;
                }
            }
            for (int j = 1; j <= m; j++) {
                minn = 0x3f3f3f3f;
                for (int i = 1; i <= n; i++) {
                    if (table[i][j] < minn) minn = table[i][j];
                }
                if (minn) {
                    tmp += minn;
                    col[j] = minn;
                    for (int i = 1; i <= n; i++) table[i][j] -= minn;
                }
            }
        } else {
            for (int j = 1; j <= m; j++) {
                minn = 0x3f3f3f3f;
                for (int i = 1; i <= n; i++) {
                    if (table[i][j] < minn) minn = table[i][j];
                }
                if (minn) {
                    tmp += minn;
                    col[j] = minn;
                    for (int i = 1; i <= n; i++) table[i][j] -= minn;
                }
            }
            for (int i = 1; i <= n; i++) {
                minn = 0x3f3f3f3f;
                for (int j = 1; j <= m; j++) {
                    if (table[i][j] < minn) minn = table[i][j];
                }
                if (minn) {
                    tmp += minn;
                    row[i] = minn;
                    for (int j = 1; j <= m; j++) table[i][j] -= minn;
                }
            }
        }
        flag = 1;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++)
                if (table[i][j]) {
                    flag = 0;
                    break;
                }
        if (flag) {
            cout << tmp << '\n';
            for (int i = 1; i <= n; i++) {
                for (int k = 1; k <= row[i]; k++) cout << "row " << i << '\n';
            }
            for (int j = 1; j <= m; j++) {
                for (int k = 1; k <= col[j]; k++) cout << "col " << j << '\n';
            }
        } else
            cout << "-1\n";
    }
    return 0;
}

9
row 1
row 2
row 3
row 4
row 6
row 7
row 8
row 9
row 10

9
col 1
col 2
col 3
col 4
col 5
col 6
col 8
col 9
col 10

7
row 1
row 2
row 3
row 5
col 1
col 2
col 3

7
row 1
row 2
row 3
col 1
col 2
col 3
col 5

10
col 1
col 1
col 1
col 1
col 1
col 1
col 1
col 1
col 1
col 1

9
col 1
col 1
col 1
col 2
col 2
col 2
col 3
col 3
col 3

9
col 1
col 1
col 1
col 1
col 1
col 1
col 1
col 1
col 1

11
row 2
row 3
row 3
row 4
row 4
row 4
row 5
row 5
row 5
row 5
col 1

15
col 1
col 1
col 1
col 1
col 1
col 2
col 2
col 2
col 2
col 2
col 2
col 2
col 2
col 2
col 2

12
row 2
row 2
col 1
col 1
col 1
col 2
col 2
col 2
col 2
col 3
col 3
col 3

15
row 1
row 1
row 1
row 1
row 1
row 1
row 1
row 1
row 1
row 1
row 2
row 2
row 2
row 2
row 2


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
len=1005
mod=998244353
seed=131
r,c=array of len int
dd=array of len by len int
num,n,m
flag=int
function solve1 (no args, no return value)
    for i=1 to n inclusive
        minx=10^9
        for j=1 to m inclusive minx=min(minx,dd[i][j])
        r[i]=minx
        if r[i] is not 0 add minx to num
        for j=1 to m inclusive subtract minx from dd[i][j]
    end of the block
    for j=1 to m inclusive
        minx=10^9
        for i=1 to n inclusive minx=min(minx,dd[i][j])
        c[j]=minx
        if minx is not 0 add minx to num
        for i=1 to n inclusive
            subtract minx from dd[i][j]
            if dd[i][j] flag=1
        end of the block
    end of the block
end of the block
function solve1 (no args, no return value)
    for j=1 to m inclusive
        minx=10^9
        for i=1 to n inclusive minx=min(minx,dd[i][j])
        c[j]=minx
        if minx is not 0 add minx to num
        for i=1 to n inclusive subtract minx from dd[i][j]
    end of the block
    for i=1 to n inclusive
        minx=10^9
        for j=1 to m inclusive minx=min(minx,dd[i][j])
        r[i]=minx
        if r[i] is not 0 add minx to num
        for j=1 to m inclusive
            subtract minx from dd[i][j]
            if dd[i][j] flag=1
        end of the block
    end of the block
end of the block
define the main function
    read n,m
    for i=1 to n inclusive
        for j=1 to m inclusive read dd[i][j]
    if n<=m
        solve1()
    else
        solve2()
    if flag print -1 and return 0
    print num
    for i=1 to n inclusive
        for j=0 to r[i] exclusive print "row ", i
    end of the block
    for i=1 to m inclusive
        for j=0 to c[i] exclusive print "col ", i
end of the block

[CODE]:

const int len = 1e3 + 5;
const long long mod = 998244353;
const ulong long seed = 131;
int r[len], c[len];
int dd[len][len];
int num, n, m;
int flag;
void solve1() {
    for (int i = 1; i <= n; ++i) {
        int minx = 1e9;
        for (int j = 1; j <= m; ++j) minx = min(minx, dd[i][j]);
        r[i] = minx;
        if (r[i] != 0) num += minx;
        for (int j = 1; j <= m; ++j) dd[i][j] -= minx;
    }
    for (int j = 1; j <= m; ++j) {
        int minx = 1e9;
        for (int i = 1; i <= n; ++i) minx = min(minx, dd[i][j]);
        c[j] = minx;
        if (minx != 0) num += minx;
        for (int i = 1; i <= n; ++i) {
            dd[i][j] -= minx;
            if (dd[i][j]) flag = 1;
        }
    }
}
void solve2() {
    for (int j = 1; j <= m; ++j) {
        int minx = 1e9;
        for (int i = 1; i <= n; ++i) minx = min(minx, dd[i][j]);
        c[j] = minx;
        if (minx != 0) num += minx;
        for (int i = 1; i <= n; ++i) dd[i][j] -= minx;
    }
    for (int i = 1; i <= n; ++i) {
        int minx = 1e9;
        for (int j = 1; j <= m; ++j) minx = min(minx, dd[i][j]);
        r[i] = minx;
        if (r[i] != 0) num += minx;
        for (int j = 1; j <= m; ++j) {
            dd[i][j] -= minx;
            if (dd[i][j]) flag = 1;
        }
    }
}
int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) cin >> dd[i][j];
    if (n <= m)
        solve1();
    else
        solve2();
    if (flag) return puts("-1"), 0;
    cout << num << endl;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < r[i]; ++j) cout << "row " << i << endl;
    }
    for (int i = 1; i <= m; ++i)
        for (int j = 0; j < c[i]; ++j) cout << "col " << i << endl;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
make static int mod = 1e9 + 7
define the main function
    make int n, m, array row of size 105, array col of size 105, multidimensional array table of size 105x105, minn, and flag
    while read n and m
        set flag to 0
        set row elements to 0
        set col elements to 0
        for i = 1 to n inclusive
            for j = 1 to m inclusive, read table[i][j]
        end of the block
        if m greater than or equal to n
            for i = 1 to n inclusive
                set minn to 0x3f3f3f3f
                for j = 1 to m inclusive
                    if table[i][j] less than minn, set minn to table[i][j]
                end of the block
                if minn
                    set row[i] to minn
                    for j = 1 to m inclusive, subtract minn from table[i][j]
                end of the block
            end of the block
            for j = 1 to m inclusive
                set minn to 0x3f3f3f3f
                for i = 1 to n inclusive
                    if table[i][j] less than minn, set minn to table[i]j]
                end of the block
                if minn
                    set col[j] to minn
                    for i = 1 to n inclusive, subtract minn from table[i][j]
                end of the block
            end of the block
        else
            for j = 1 to m inclusive
                set minn to 0x3f3f3f3f
                for i = 1 to n inclusive
                    if table[i][j] less than minn, set minn to table[i][j]
                end of the block
                if minn
                    set col[j] to minn
                    for i = 1 to n inclusive, subtract minn from table[i][j]
                end of the block
            end of the block
            for i = 1 to n inclusive
                set minn to 0x3f3f3f3f
                for j = 1 to m inclusive
                    if table[i][j] is less than minn, set minn to table[i][j]
                end of the block
                if minn
                    set row[i] to minn
                    for j = 1 to m inclusive, decrease table[i][j] by minn
                end of the block
            end of the block
        end of the block
        set flag to 1
        for i = 1 to n inclusive
            for j = 1 to m inclusive
                if table[i][j]
                    set flag to 0
                    break
                end of the block
            end of the block
        if flag
            make int tmp = 0
            for i = 1 to n inclusive, increase tmp by row[i]
            for j = 1 to m inclusive, increase tmp by col[j]
            print tmp
            for i = 1 to n inclusive
                for k = 1 to row[i] inclusive, print "row " i
            end of the block
            for j = 1 to m inclusive
                for k = 1 to col[j] inclusive, print "col " j
            end of the block
        else
            print "-1\n"
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

static int mod = 1e9 + 7;
int main() {
    int n, m, row[105], col[105], table[105][105], minn, flag;
    while (cin >> n >> m) {
        flag = 0;
        memset(row, 0, sizeof(row));
        memset(col, 0, sizeof(col));
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) cin >> table[i][j];
        }
        if (m >= n) {
            for (int i = 1; i <= n; i++) {
                minn = 0x3f3f3f3f;
                for (int j = 1; j <= m; j++) {
                    if (table[i][j] < minn) minn = table[i][j];
                }
                if (minn) {
                    row[i] = minn;
                    for (int j = 1; j <= m; j++) table[i][j] -= minn;
                }
            }
            for (int j = 1; j <= m; j++) {
                minn = 0x3f3f3f3f;
                for (int i = 1; i <= n; i++) {
                    if (table[i][j] < minn) minn = table[i][j];
                }
                if (minn) {
                    col[j] = minn;
                    for (int i = 1; i <= n; i++) table[i][j] -= minn;
                }
            }
        } else {
            for (int j = 1; j <= m; j++) {
                minn = 0x3f3f3f3f;
                for (int i = 1; i <= n; i++) {
                    if (table[i][j] < minn) minn = table[i][j];
                }
                if (minn) {
                    col[j] = minn;
                    for (int i = 1; i <= n; i++) table[i][j] -= minn;
                }
            }
            for (int i = 1; i <= n; i++) {
                minn = 0x3f3f3f3f;
                for (int j = 1; j <= m; j++) {
                    if (table[i][j] < minn) minn = table[i][j];
                }
                if (minn) {
                    row[i] = minn;
                    for (int j = 1; j <= m; j++) table[i][j] -= minn;
                }
            }
        }
        flag = 1;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++) {
                if (table[i][j]) {
                    flag = 0;
                    break;
                }
            }
        if (flag) {
            int tmp = 0;
            for (int i = 1; i <= n; i++) { tmp += row[i]; }
            for (int j = 1; j <= m; j++) { tmp += col[j]; }
            cout << tmp << '\n';
            for (int i = 1; i <= n; i++) {
                for (int k = 1; k <= row[i]; k++) cout << "row " << i << '\n';
            }
            for (int j = 1; j <= m; j++) {
                for (int k = 1; k <= col[j]; k++) cout << "col " << j << '\n';
            }
        } else
            cout << "-1\n";
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
let INF be const integer with INF = 0x3f3f3f3f
define the main function
    let n, m be integers
    read n, m
    let ans, ar be array of size 105 by 105 with ans = ar = {0}
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            read ans[i][j]
            set ar[i][j] to ans[i][j]
        end of the block
    let mins, sum be integers with mins = INF and sum = 0
    let temp be integer array of size 6 by 200 with temp = {0}
    for i = 1 to n inclusive
        set mins to INF
        for j = 1 to m inclusive, set mins to min of mins, ans[i][j]
        set temp[1][i] to mins
        for j = 1 to m inclusive, set ans[i][j] to ans[i][j] - mins
    end of the block
    for j = 1 to m inclusive
        set mins to INF
        for i = 1 to n inclusive, set mins to min of mins, ans[i][j]
        set temp[2][j] to mins
        for i = 1 to n inclusive, decrement ans[i][j] by mins
    end of the block
    for j = 1 to m inclusive
        set mins to INF
        for i = 1 to n inclusive, set mins to min of mins, ar[i][j]
        set temp[3][j] to mins
        for i = 1 to n inclusive, set ar[i][j] to ar[i][j] - mins
    end of the block
    for i = 1 to n inclusive
        set mins to iNF
        for j = 1 to m inclusive, mins = min of mins, ar[i][j]
        temp[4][i] = mins
        for j = 1 to m inclusive, decrement ar[i][j] by mins
    end of the block
    let flag1, flag2 be integers with flag1 = flag2 = 0
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            if ans[i][j] != 0
                set flag1 to 1
                break
            end of the block
        end of the block
    end of the block
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            if ar[i][j] != 0
                set flag2 to 0
                break
            end of the block
        end of the block
    end of the block
    if flag1 == 1 and flag2 == 1
        print -1
    else if flag1 == 0 and flag2 == 0
        sum1 = sum2 = integer = 0
        for i = 1 to n inclusive
            increment sum1 by temp[1][i]
            increment sum2 by temp[4][i]
        end of the block
        for j = 1 to m inclusive
            increment sum1 by temp[2][j]
            increment sum2 by temp[3][j]
        end of the block
        if sum1 > sum2
            print sum2
            for i = 1 to n inclusive
                for j = 1 to temp[4][i], print row, i
            for j = 1 to m inclusive
                for i = 1 to temp[3][j] inclusive, print col, j
        else
            print sum1
            for i = 1 to n inclusive
                for j = 1 to temp[1][i], print "row ", i
            for j = 1 to m inclusive
                for i = 1 to temp[2][j] inclusive, print "col ", j
        end of the block
    else if flag1 == 1
        let sum2 be integer with sum2 = 0
        for i = 1 to n inclusive, increment sum2 by temp[4][i]
        for j = 1 to n inclusive, increment sum2 by temp[3][j]
        print sum2
        for i = 1 to n inclusive
            for j = 1 to temp[4][i] inclusive, print "row ", i
        for j = 1 to m inclusive
            for i = 1 to temp[3][j] inclusive, print "col ", j
    else if flag2 == 1
        sum1 = int = 0
        for i = 1 to n inclusive, increment sum1 by temp[4][i]
        for j = 1 to n inclusive, increment sum1 by temp[3][j]
        print sum1
        for i = 1 to n inclusive
            for j = 1 to temp[1][i] inclusive, print "row ", i
        for j = 1 to m inclusive
            for i = 1 to temp[2][j] inclusive, print "col ", j
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

const int INF = 0x3f3f3f3f;
int main() {
    int n, m;
    cin >> n >> m;
    int ans[105][105] = {0}, ar[105][105] = {0};
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            cin >> ans[i][j];
            ar[i][j] = ans[i][j];
        }
    int mins = INF, sum = 0;
    int temp[6][200] = {0};
    for (int i = 1; i <= n; i++) {
        mins = INF;
        for (int j = 1; j <= m; j++) mins = min(mins, ans[i][j]);
        temp[1][i] = mins;
        for (int j = 1; j <= m; j++) ans[i][j] -= mins;
    }
    for (int j = 1; j <= m; j++) {
        mins = INF;
        for (int i = 1; i <= n; i++) mins = min(mins, ans[i][j]);
        temp[2][j] = mins;
        for (int i = 1; i <= n; i++) ans[i][j] -= mins;
    }
    for (int j = 1; j <= m; j++) {
        mins = INF;
        for (int i = 1; i <= n; i++) mins = min(mins, ar[i][j]);
        temp[3][j] = mins;
        for (int i = 1; i <= n; i++) ar[i][j] -= mins;
    }
    for (int i = 1; i <= n; i++) {
        mins = INF;
        for (int j = 1; j <= m; j++) mins = min(mins, ar[i][j]);
        temp[4][i] = mins;
        for (int j = 1; j <= m; j++) ar[i][j] -= mins;
    }
    int flag1 = 0, flag2 = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (ans[i][j] != 0) {
                flag1 = 1;
                break;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (ar[i][j] != 0) {
                flag2 = 1;
                break;
            }
        }
    }
    if (flag1 == 1 && flag2 == 1)
        cout << -1 << endl;
    else if (flag1 == 0 && flag2 == 0) {
        int sum1 = 0, sum2 = 0;
        for (int i = 1; i <= n; i++) {
            sum1 += temp[1][i];
            sum2 += temp[4][i];
        }
        for (int j = 1; j <= m; j++) {
            sum1 += temp[2][j];
            sum2 += temp[3][j];
        }
        if (sum1 > sum2) {
            cout << sum2 << endl;
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= temp[4][i]; j++) cout << "row " << i << endl;
            for (int j = 1; j <= m; j++)
                for (int i = 1; i <= temp[3][j]; i++) cout << "col " << j << endl;
        } else {
            cout << sum1 << endl;
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= temp[1][i]; j++) cout << "row " << i << endl;
            for (int j = 1; j <= m; j++)
                for (int i = 1; i <= temp[2][j]; i++) cout << "col " << j << endl;
        }
    } else if (flag1 == 1) {
        int sum2 = 0;
        for (int i = 1; i <= n; i++) { sum2 += temp[4][i]; }
        for (int j = 1; j <= m; j++) { sum2 += temp[3][j]; }
        cout << sum2 << endl;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= temp[4][i]; j++) cout << "row " << i << endl;
        for (int j = 1; j <= m; j++)
            for (int i = 1; i <= temp[3][j]; i++) cout << "col " << j << endl;
    } else if (flag2 == 1) {
        int sum1 = 0;
        for (int i = 1; i <= n; i++) { sum1 += temp[4][i]; }
        for (int j = 1; j <= m; j++) { sum1 += temp[3][j]; }
        cout << sum1 << endl;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= temp[1][i]; j++) cout << "row " << i << endl;
        for (int j = 1; j <= m; j++)
            for (int i = 1; i <= temp[2][j]; i++) cout << "col " << j << endl;
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
declare constant integer M = 2e5 + 5
declare integer arrays G size 200 by 200, T size 200 by 200
define the main function
    declare integers n, m, i, j
    read n, m
    declare boolean f = 0
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            read G[i][j]
            let T[i][j] be G[i][j]
        end of the block
    declare integer vectors r,, c
    for i = 1 to n inclusive
        declare integer mn = 1000
        for j = 1 to m inclusive, let mn be minimum of ( mn and G[i][j] )
        for j = 1 to m inclusive, decrement G[i][j] by mn
        for j = 1 to mn inclusive, add i to end of r
    end of the block
    for i = 1 to m inclusive
        declare integer mn = 1000
        for j = 1 to n inclusive, let mn be minimum of ( mn and G[j][i] )
        for j = 1 to n inclusive, decrement G[j][i] by mn
        for j = 1 to mn inclusive, add i to end of c
    end of the block
    for i = 1 to n inclusive
        for j = 1 to m inclusive
            if G[i][j] is true
                print "-1\n"
                return to indicate successful execution
            end of the block
            let G[i][j] be T[i][j]
        end of the block
    declare integer vectors r1, c1
    for i = 1 to m inclusive
        declare integer mn = 1000
        for j = 1 to n inclusive, let mn be minimum of ( mn and G[j][i] )
        for j = 1 to n inclusive, decrement G[j][i] by mn
        for j = 1 to mn inclusive, add i to end of c1
    end of the block
    for i = 1 to n inclusive
        declare integer mn = 1000
        for j = 1 to n inclusive, let mn be minimum of ( mn and G[j][i] )
        for j = 1 to n inclusive, decrement G[j][i] by mn
        for j = 1 to mn inclusive, add i to end of r1
    end of the block
    if size of r + size of c is greater than size of r1 + size of c1
        let r be r1
        let c be c1
    end of the block
    print size of r + size of c, "\n"
    for i = 0 to size of r exclusive
        print "row "
        print r[i], "\n"
    end of the block
    for i = 0 to size of c exclusive
        print "col "
        print c[i], "\n"
    end of the block
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
create pair of integer, integer array par with size 10001
create string set str
define the main function
    create string s
    create integers n, i
    read n read s
    if n is 8
        print "vaporeon" print newline
    else if n is 6
        print "espeon" print newline
    else if n is 7
        if s[0] is '.'
            if s[1] is 'o'
                print "jolteon" print newline
                return to indicate successful execution
            end of the block
            if s[1] is 'm'
                print "umbreon" print newline
                return to indicate successful execution
            end of the block
            if s[1] is 'e'
                print "leafeon" print newline
                return to indicate successful execution
            end of the block
            if s[1] is 'y'
                print "sylveon" print newline
                return to indicate successful execution
            end of the block
            if s[1] is 'l'
                if s[3] is 'r'
                    print "flareon" print newline
                    return to indicate successful execution
                else
                    print "glaceon" print newline
                    return to indicate successful execution
                end of the block
            end of the block
            if s[1] is '.'
                if s[2] is 'b'
                    print "umbreon" print newline
                    return to indicate successful execution
                end of the block
                if s[2] is 'l'
                    if s[3] is 't'
                        print "jolteon" print newline
                        return to indicate successful execution
                    else
                        print "sylveon" print newline
                        return to indicate successful execution
                    end of the block
                end of the block
                if s[2] is 'a'
                    if s[3] is 'r'
                        print "flareon" print newline
                        return to indicate successful execution
                    end of the block
                    if s[3] is 'c'
                        print "glaceon" print newline
                        return to indicate successful execution
                    else
                        print "leafeon" print newline
                        return to indicate successful execution
                    end of the block
                end of the block
                if s[2] is '.'
                    if s[3] is 'r'
                        print "flareon" print newline
                        return to indicate successful execution
                    end of the block
                    if s[3] is 'c'
                        print "glaceon" print newline
                        return to indicate successful execution
                    end of the block
                    if s[3] is 'f'
                        print "leafeon" print newline
                        return to indicate successful execution
                    end of the block
                    if s[3] is 't'
                        print "jolteon" print newline
                        return to indicate successful execution
                    end of the block
                    if s[3] is 'v'
                        print "sylveon" print newline
                        return to indicate successful execution
                    else
                        print "umbreon" print newline
                        return to indicate successful execution
                    end of the block
                end of the block
            end of the block
        end of the block
        if s[0] is 'j'
            print "jolteon" print newline
            return to indicate successful execution
        end of the block
        if s[0] is 'f'
            print 'flareon" print newline
            return to indicate successful execution
        end of the block
        if s[0] is 'u'
            print "umbreon" print newline
            return to indicate successful execution
        end of the block
        if s[0] is 'l'
            print "leafeon" print newline
            return to indicate successful execution
        end of the block
        if s[0] is 'g'
            print "glaceon" print newline
            return to indicate successful execution
        end of the block
        if s[0] is 's'
            print "sylveon" print newline
            return to indicate successful execution
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

pair<int, int> par[10001];
set<string> str;
int main() {
    string s;
    int n, i;
    cin >> n >> s;
    if (n == 8)
        cout << "vaporeon" << endl;
    else if (n == 6)
        cout << "espeon" << endl;
    else if (n == 7) {
        if (s[0] == '.') {
            if (s[1] == 'o') {
                cout << "jolteon" << endl;
                return 0;
            }
            if (s[1] == 'm') {
                cout << "umbreon" << endl;
                return 0;
            }
            if (s[1] == 'e') {
                cout << "leafeon" << endl;
                return 0;
            }
            if (s[1] == 'y') {
                cout << "sylveon" << endl;
                return 0;
            }
            if (s[1] == 'l') {
                if (s[3] == 'r') {
                    cout << "flareon" << endl;
                    return 0;
                } else {
                    cout << "glaceon" << endl;
                    return 0;
                }
            }
            if (s[1] == '.') {
                if (s[2] == 'b') {
                    cout << "umbreon" << endl;
                    return 0;
                }
                if (s[2] == 'l') {
                    if (s[3] == 't') {
                        cout << "jolteon" << endl;
                        return 0;
                    } else {
                        cout << "sylveon" << endl;
                        return 0;
                    }
                }
                if (s[2] == 'a') {
                    if (s[3] == 'r') {
                        cout << "flareon" << endl;
                        return 0;
                    }
                    if (s[3] == 'c') {
                        cout << "glaceon" << endl;
                        return 0;
                    } else {
                        cout << "leafeon" << endl;
                        return 0;
                    }
                }
                if (s[2] == '.') {
                    if (s[3] == 'r') {
                        cout << "flareon" << endl;
                        return 0;
                    }
                    if (s[3] == 'c') {
                        cout << "glaceon" << endl;
                        return 0;
                    }
                    if (s[3] == 'f') {
                        cout << "leafeon" << endl;
                        return 0;
                    }
                    if (s[3] == 't') {
                        cout << "jolteon" << endl;
                        return 0;
                    }
                    if (s[3] == 'v') {
                        cout << "sylveon" << endl;
                        return 0;
                    } else {
                        cout << "umbreon" << endl;
                        return 0;
                    }
                }
            }
        }
        if (s[0] == 'j') {
            cout << "jolteon" << endl;
            return 0;
        }
        if (s[0] == 'f') {
            cout << "flareon" << endl;
            return 0;
        }
        if (s[0] == 'u') {
            cout << "umbreon" << endl;
            return 0;
        }
        if (s[0] == 'l') {
            cout << "leafeon" << endl;
            return 0;
        }
        if (s[0] == 'g') {
            cout << "glaceon" << endl;
            return 0;
        }
        if (s[0] == 's') {
            cout << "sylveon" << endl;
            return 0;
        }
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    str = string array of size 12
    n, i, j, ck = int
    read n then str[0]
    set str[1] to "vaporeon"
    set str[2] to "jolteon"
    set str[3] to "flareon"
    set str[4] to "espeon"
    set str[5] to "umbreon"
    set str[6] to "leafeon"
    set str[7] to "glaceon"
    set str[8] to "sylveon"
    for i = 1 to 8 inclusive
        if size of str[i] is n
            set ck to 1
            for j = 0 to n
                if str[0][j] >= 'a' and str[0][j] <= 'z'
                    if str[0][j] is not str[i][j]
                        set ck to 0
                        break
                    end of the block
                end of the block
            end of the block
            if ck is 1
                print str[i]
                return to indicate successful execution
            end of the block
        end of the block
    end of the block
    print newline
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    string str[12];
    int n, i, j, ck;
    cin >> n >> str[0];
    str[1] = "vaporeon";
    str[2] = "jolteon";
    str[3] = "flareon";
    str[4] = "espeon";
    str[5] = "umbreon";
    str[6] = "leafeon";
    str[7] = "glaceon";
    str[8] = "sylveon";
    for (i = 1; i <= 8; i++) {
        if (str[i].size() == n) {
            ck = 1;
            for (j = 0; j < n; j++) {
                if (str[0][j] >= 'a' && str[0][j] <= 'z') {
                    if (str[0][j] != str[i][j]) {
                        ck = 0;
                        break;
                    }
                }
            }
            if (ck == 1) {
                cout << str[i] << endl;
                return 0;
            }
        }
    }
    cout << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create integer N
    create string jolteon with jolteon = "jolteaon"
    create integer jol with jol = 0
    create string flareon with flareon = "flareon"
    create integer fla with fla = 0
    create string umbreon with umbreon = "umbreon"
    create integer umb with umb = 0
    create string leafeon with leafeon = "leafeon"
    create integer leaf with leaf = 0
    create string glaceon with glaceon = "glaceon"
    create integer gla with gla = 0
    create string sylveon with sylveon = "sylveon"
    create integer syl with syl = 0
    create string eevee
    read N
    read eevee
    if N is 8
        print "vaporeon\n"
    else if N is 6
        print "espeon\n"
    else
        for x = 0 to N exclusive
            if eevee[x] is not '.'
                iif eevee[x] is flareon[x] and fla is 0
                    if x is not 2, set leaf to 1
                    set jol to 1
                    set syl to 1
                    set umb to 1
                    if x is not 1 and x is not 2, set gla to 1
                end of the block
                if eevee[x] is glaceon[x] and gla is 0
                    if x is not 2, set leaf to 1
                    set jol to 1
                    set syl to 1
                    set umb to 1
                    if x is not 1 and x is not 2, set fla to 1
                end of the block
                if eevee[x] is leafeon[x] and leaf is 0
                    if x is not 2
                        set fla to 1
                        set gla to 1
                    end of the block
                    set jol to 1
                    set syl to 1
                    set umb to 1
                end of the block
                if eevee[x] is jolteon[x] and jol is 0
                    set leaf to 1
                    set fla to 1
                    if x is not 2, set syl to 1
                    set umb to 1
                    set gla to 1
                end of the block
                if eevee[x] is umbreon[x] and umb is 0
                    set leaf to 1
                    set jol to 1
                    set syl to 1
                    set fla to 1
                    set gla to 1
                end of the block
                if eevee[x] is sylveon[x] and syl is 0
                    set leaf to 1
                    set fla to 1
                    if x is not 2, set jol to 1
                    set umb to 1
                    set gla to 1
                end of the block
                if syl + leaf + jol + umb + gla + fla is 5
                    if syl is 0, print sylveon print "\n"
                    if gla is 0, print glaceon print "\n"
                    if fla is 0, print flareon print "\n"
                    if jol is 0, print jolteon print "\n"
                    if umb is 0 print umbreon print "\n"
                    if leaf is 0 print leafon print "\n"
                    break loop
                end of the block
            end of the block
        end of the block
    end of the block
end of the block

[CODE]:

int main() {
    int N;
    string jolteon = "jolteon";
    int jol = 0;
    string flareon = "flareon";
    int fla = 0;
    string umbreon = "umbreon";
    int umb = 0;
    string leafeon = "leafeon";
    int leaf = 0;
    string glaceon = "glaceon";
    int gla = 0;
    string sylveon = "sylveon";
    int syl = 0;
    string eevee;
    cin >> N;
    cin >> eevee;
    if (N == 8) {
        cout << "vaporeon\n";
    } else if (N == 6) {
        cout << "espeon\n";
    } else {
        for (int x = 0; x < N; x++) {
            if (eevee[x] != '.') {
                if (eevee[x] == flareon[x] && fla == 0) {
                    if (x != 2) { leaf = 1; }
                    jol = 1;
                    syl = 1;
                    umb = 1;
                    if (x != 1 && x != 2) { gla = 1; }
                }
                if (eevee[x] == glaceon[x] && gla == 0) {
                    if (x != 2) { leaf = 1; }
                    jol = 1;
                    syl = 1;
                    umb = 1;
                    if (x != 1 && x != 2) { fla = 1; }
                }
                if (eevee[x] == leafeon[x] && leaf == 0) {
                    if (x != 2) {
                        fla = 1;
                        gla = 1;
                    }
                    jol = 1;
                    syl = 1;
                    umb = 1;
                }
                if (eevee[x] == jolteon[x] && jol == 0) {
                    leaf = 1;
                    fla = 1;
                    if (x != 2) { syl = 1; }
                    umb = 1;
                    gla = 1;
                }
                if (eevee[x] == umbreon[x] && umb == 0) {
                    leaf = 1;
                    jol = 1;
                    syl = 1;
                    fla = 1;
                    gla = 1;
                }
                if (eevee[x] == sylveon[x] && syl == 0) {
                    leaf = 1;
                    fla = 1;
                    if (x != 2) { jol = 1; }
                    umb = 1;
                    gla = 1;
                }
                if (syl + leaf + jol + umb + gla + fla == 5) {
                    if (syl == 0) { cout << sylveon << "\n"; }
                    if (gla == 0) { cout << glaceon << "\n"; }
                    if (fla == 0) { cout << flareon << "\n"; }
                    if (jol == 0) { cout << jolteon << "\n"; }
                    if (umb == 0) { cout << umbreon << "\n"; }
                    if (leaf == 0) { cout << leafeon << "\n"; }
                    break;
                }
            }
        }
    }
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    a,n,b,c=int
    s=array of 8 char
    w=array of 8 char filled with "jolteon", q=array of 8 char filled with "flareon"
    v=array of 8 char filled with "umbreon", z=array of 8 char filled with "leafeon", l=array of 8 char filled with "glaceeon", m=array of 8 char filled with "sylveon"
    read n
    read s
    if n is 8
        print "vaporeon"
    else if n is 6
        print "espeon"
    else
        a=0
        b=0
        c=0
        d=0
        e=0
        f=0
        for i=0 to 8 exclusive
            if s[i] is w[i] increment a
        end of the block
        for i=0 to 8 exclusive
            if s[i] is q[i] increment b
        end of the block
        for i=0 to 8 exclusive
            if s[i] is v[i] increment c
        end of the block
        for i=0 to 8 exclusive
            if s[i] is z[i] increment d
        end of the block
        for i=0 to 8 exclusive
            if s[i] is l[i] increment e
        end of the block
        for i=0 to 8 exclusive
            if s[i] is m[i] increment f
        end of the block
        if a>b and a>c and a>d and a>e and a>f
            print "jolteon"
        if b>a and b>c and b>d and b>e and b>f
            print "flareon"
        if c>a and c>b and c>d and c>e and c>f
            print "umbreon"
        if d>a and d>b and d>c and d>e and d>f
            print "leafeon"
        if e>a and e>b and e>c and e>d and e>f
            print "glaceon"
        if f>a and f>b and f>c and f>d and f>e
            print "sylveon"
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    int a, n, b, c;
    char s[8];
    char w[8] = "jolteon", q[8] = "flareon";
    char v[8] = "umbreon", z[8] = "leafeon", l[8] = "glaceon", m[8] = "sylveon";
    cin >> n;
    cin >> s;
    if (n == 8) {
        cout << "vaporeon" << endl;
    } else if (n == 6) {
        cout << "espeon" << endl;
    } else {
        a = 0;
        b = 0;
        c = 0;
        int d = 0;
        int e = 0;
        int f = 0;
        for (int i = 0; i < 8; i++) {
            if (s[i] == w[i]) { a++; }
        }
        for (int i = 0; i < 8; i++) {
            if (s[i] == q[i]) { b++; }
        }
        for (int i = 0; i < 8; i++) {
            if (s[i] == v[i]) { c++; }
        }
        for (int i = 0; i < 8; i++) {
            if (s[i] == z[i]) { d++; }
        }
        for (int i = 0; i < 8; i++) {
            if (s[i] == l[i]) { e++; }
        }
        for (int i = 0; i < 8; i++) {
            if (s[i] == m[i]) { f++; }
        }
        if (a > b && a > c && a > d && a > e && a > f) {
            cout << "jolteon" << endl;
        } else if (b > a && b > c && b > d && b > e && b > f) {
            cout << "flareon" << endl;
        } else if (c > a && c > b && c > d && c > e && c > f) {
            cout << "umbreon" << endl;
        } else if (d > a && d > c && d > b && d > e && d > f) {
            cout << "leafeon" << endl;
        } else if (e > a && e > c && e > d && e > b && e > f) {
            cout << "glaceon" << endl;
        } else if (f > a && f > c && f > d && f > e && f > b) {
            cout << "sylveon" << endl;
        }
    }
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
create long long integers x and y
declare exgcd taking in long long integers a and returning long longand b
    if b is equal to 0
        set x to 1
        set y to 0
        return a
    end of the block
    create long long d = exgcd(b, a % b)
    create long long t = x
    set x to y
    set y to the result of t - a / b * y
    return d
end of the block
define the main function
    create long long integers m, h1, al, x1, y1, h2, a2, x2, y2
    create long long integers p1, p2, q1, q2
    while cin >> m >> h1 >> a1 >> x1 >> y1 >> h2 >> a2 >> x2 >> y2 is truthy
        set p1, p2, q1, and q1 to 0
        for i = 1 to 2 * m
            set h1 to (h1 * x1 + y1) % m
            if h1 is equal to a1
                if p1 is equal to 0
                    set p1 to i
                else if q1 is equal to 0
                    set q1 to the result of i - p1
                    break loop
                end of the block
            end of the block
        end of the block
        for i = 1 to 2 * m
            set h2 to the result of (h2 * x2 + y2) % m
            if h2 is equal to a2
                if p2 is equal to 0
                    set p2 to i
                else if q2 is equal to 0
                    set q2 to the result of i - p2
                    break loop
                end of the block
            end of the block
        end of the block
        create long long d = exgcd(q1, -q2)
        create long long c = p2 - p1
        if d is equal to 0
            print "-1"
            continue to next loop iteration
        end of the block
        if c modulo d is truthy
            print "-1"
            continue to next loop iteration
        end of the block
        if d is less than 0, set d to -d
        if p1 is equal to 0 or p2 is equal to 0
            print "-1"
            continue to next loop iteration
        end of the block
        if q2 is equal to 0 and q1 is equal to 0 and p1 is not equal to p2
            print "-1"
            continue to next loop iteration
        end of the block
        if q2 is equal to 0 and p2 - p1 is less than 0 or q1 is equal to 0 and p1 - p2 is less than 0
            print "-1"
            continue to next loop iteration
        end of the block
        create long long k = c / d
        if the return value of exgcd(q1, -q2) is less than 0, set x to -x and set y to -y
        set x to the result of x * k
        set y to the result of y * k
        if x is less than 0 or y is less than 0
            while 1 is truthy
                set x to the result of x + q2 / d
                set y to the result of y + q1 / d
                if x is greater than or equal to 0 and y is greater than or equal to 0, break loop
            end of the block
        end of the block
        if x is greater than 0 and y is greater then 0
            while 1 is truthy
                set x to the result of x - q2 / d
                set y to the result of y - q1 / d
                if x is less than 0 or y is less than 0, break loop
            end of the block
            set x to the result of x + q2 / d
            set y to the result of y + q1 / d
        end of the block
        create long long ans = x * q1 + p1
        print ans
    end of the block
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
vis1 = array of long integers of length 1000005
vis2 = array of long integers of length 1000005
define the main function
    let m be a long integer
    let h1, a1 be long integers
    let x1, y1 be long integers
    let h2, a2 be long integers
    let x2, y2 be long integers
    read m, h1, a1, x1, y1, h2, a2, x2, y2
    memset of vis1, 0, size of vis1
    memset of vis2, 0, size of vis2
    let t1, t2 be long integers with t1 = -1, t2 = -1
    let c1, c2 be long integers with c1 = -1, c2 = -1
    let q1, q2 be long integers with q1 = -1, q2 = -1
    let f1, f2 be long integers with f1 = -1, f2 = -1
    set boolean value flag to true
    set boolean value fuck to false
    for long integer i = 1 to 2 * m inclusive
        the value of h1 = h1 * x1
        the value of h1 = h1 modulo m
        the value of h1 = h1 + y1
        the value of h1 = h1 modulo m
        the value of h2 = h2 * x2
        the value of h2 = h2 modulo m
        the value of h2 = h2 + y2
        the value of h2 = h2 modulo m
        if h1 is equal to a1 and a2 is equal to h2
            set fuck to true
            print i and newline
            stop
        end of the block
        if vis1[a1] is equal to 0 and h1 is equal to a1, f1 is equal to i
        if vis2[a2] is equal to 0 and h2 is equal to a2, f2 is equal to i
        if h1 is equal to a1 and t1 is equal to -1, c1 is equal to i
        if h2 is equal to a2 and t2 is equal to -1, c2 is equal to i
        if vis1[h1] is not equal to 0 and q1 is equal to -1
            the value of q1 is equal to vis1[h1]
            the value of t1 is equal to i - q1
            if c1 is less than q1
                set flag to false
                stop
            else do the following
                decrement c1 by q1
            end of the block
        end of the block
        if vis2[h2] is not equal to 0 and q2 is equal to -1
            the value of q2 is equal to vis2[h2]
            the value of t2 is equal to i - q2
            if c2 is less than q2
                set flag to false
                stop
            else do the following
                decrement c2 by q2
            end of the block
        end of the block
        if t1 is not equal to -1 and t2 is not equal to -1, stop
        if vis1[h1] is equal to 0, vis1[h1] is equal to i
        if vis2[h2] is equal to 0, vis2[h2] is equal to i
    end of the block
    if fuck is true
    else if not flag
        if f1 is not equal to f2 or f1 is equal to -1 or f2 is equal to -1
            print -1 and newline
        else do the following
            print f1 + 1 and newline
    else do the following
        if f1 is equal to f2 and f1 is not equal to -1 and f2 is not equal to -2
            print f1 and newline
        else if t1 is equal to t2 and (c1 is equal to c2 and f1 is not equal to f2) or c1 is not equal to c2
            print -1 and newline
        end of the block
        else do the following
            let x be a long integer with x = 0
            while x * t1 + c1 + q1 - c2 - q2 modulo t2 is not equal to 0
                increment x by 1
                if x is greater than 1000000, stop
            end of the block
            if x is greater than 1000000
                print -1 and newline
            else do the following
                print x * t1 + c1 + q1 and newline
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
create integers m, h, h2, a, a2, x, x2, y, y2
declare get with integers s, e as arguments, returning integer
    for i = 0 to m exclusive
        set s to (1ll * s * x + y ) % m
        if s is e, return i + 1
    end of the block
    return -1 from function
end of the block
declare get2 with integers s, e as arguments, returning integer
    for i = 0 to m exclusive
        set s to (1ll * s * x2 + y2 ) % m
        if s is e, return i + 1 from function
    end of the block
    return -1 from function
end of the block
define the main function
    read m read h read a read x read y read h2 read a2 read x2 read y2
    create integers t, t2 with t = result of run get with h, a as arguments, t2 = result of run get2 with h2, a2 as arguments
    if t is -1 or t2 is -1, return print "-1\n", 0 from function
    if t is t2, return print t print '\n', 0 from function
    create integers l, l2 with l = result of run get with a, a as arguments, l2 = result of run get2 with a2, a2, as arguments
    if bitwise not l and t - t2 is greater than or equal to 0 and not ( (t-t2)%l2), return print t print '\n', 0 from function
    if bitwise not l2 and t - t2 is greater than or equal to 0 and not ( (t-t2) % l2 ), return print t print '\n', 0 from function
    if l is -1 or l2 is -1, return print "-1\n", 0
    create integer val with val = t2 - t
    for i =1, lim = m bitshift left 1 to i is less than or equal to lim, incrementing i
        if (val + 1ll * i * l2 is greater than or equal to 0 and not ((val + 1ll * i * l2) % l)) return print 1ll * i * l2 + t2 print '\n', 0 from function
    print "-1\n"
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
create long longs x, y
declare exgcd with long longs a, b as arguments returning long long
    if b is 0
        set x to 1
        set y to 0
        return a from function
    end of the block
    crate long long d with d = result of run exgcd with b, a % b as arguments
    create long long t with t = x
    set x to y
    set y to t - a / b * y
    return d from function
end of the block
define the main function
    create long longs m, h1, a1, x1, y1, h2, a2, x2, y2
    create long longs p1, p2, q1, q2
    while read m read h1 read a1 read x1 read y1 read h2 read a2 read x2 read y2 is true
        set p1 to p2 to q1 to q2 to 0
        for i = 1 to 2 * m inclusive
            set h1 to (h1 * x1 + y1) % m
            if h1 is a1
                if p1 is 0
                    set p1 to i
                else if q1 is 0
                    set q1 to i - p1
                    break loop
                end of the block
            end of the block
        end of the block
        for i = 1 to 2 * m inclusive
            set h2 to (h2 * x2 + y2) % m
            if h2 is a2
                if p2 is 0
                    set p2 to i
                else if q2 is 0
                    set q2 to i - p2
                    break loop
                end of the block
            end of the block
        end of the block
        create long long d with d = result of run exgcd with q1, -q2 as arguments
        create long long c with c = p2 - p1
        if d is 0
            print "-1"
            break current loop iteration
        end of the block
        if c % d
            print "-1"
            break current loop iteration
        end of the block
        if p1 is 0 or p2 is 0
            print "-1"
            break current loop iteration
        end of the block
        if q2 is 0 and q1 is 0 and p1 is not p2
            print "-1"
            break current loop iteration
        end of the block
        if ( q2 is 0 and p2 - p1 is less than 0 ) or ( q2 is 0 and p1 - p2 is less than 0 )
            print "-1"
            break current loop iteration
        end of the block
        create long long k with k = c / d
        set x to x * k
        set y to y * k
        if d is less than 0, set d to -d
        if x is less than 0 or y is less than 0
            while 1 is true
                increment x by q2 / d
                increment y by q1 / d
                if x is greater than or equal to 0 and y is greater than or equal to 0, break loop
            end of the block
        end of the block
        if x is greater than 0 and y is greater than 0
            while 1 is true
                decrement x by q2 / d
                decrement y by q1 / d
                if x is less than 0 or y is less than 0, break loop
            end of the block
            increment x by q2 / d
            increment y by q1 / d
        end of the block
        create long long ans with ans = x * q1 + p1
        print ans print newline
    end of the block
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create long long integers m, x1, x2, y1, y2, h1, h2, a1, and a2
    read m
    read h1 and a1
    read x1 and y1
    read h2 and a2
    read x2 and y2
    create integer vector ans1
    create integer vector ans2
    create long long integer total = 0
    while total is less than 2 * m
        if h1 is equal to a1, append total to ans1
        if h2 is equal to a2, append total to ans2
        increment total
        set h1 to the result of (h1 * x1 + y1) % m
        set h2 to the result of (h2 * x2 + y2) % m;
    end of the block
    if ans1.empty() is truthy or ans2.empty() is truthy
        print "-1"
        return to indicate successful execution
    end of the block
    create long long integers t1 = ans1[0] and t2 = ans2[0]
    create long long integer s1 = ans1[1] - ans1[0]
    create long long integer s2 = ans2[1] - ans2[0]
    for i = 0 to 5e6
        if t1 is equal to t2
            print t1
            return to indicate successful execution
        end of the block
        if t1 is less than t2
            set t1 to t1 + s1
        else
            set t2 to t2 + s2
        end of the block
    end of the block
    print "-1"
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    long long m, x1, x2, y1, y2, h1, h2, a1, a2;
    cin >> m;
    cin >> h1 >> a1;
    cin >> x1 >> y1;
    cin >> h2 >> a2;
    cin >> x2 >> y2;
    vector<int> ans1;
    vector<int> ans2;
    long long total = 0;
    while (total < 2 * m) {
        if (h1 == a1) { ans1.push_back(total); }
        if (h2 == a2) { ans2.push_back(total); }
        total++;
        h1 = (h1 * x1 + y1) % m;
        h2 = (h2 * x2 + y2) % m;
    }
    if (ans1.empty() || ans2.empty()) {
        cout << "-1" << endl;
        return 0;
    }
    long long t1 = ans1[0], t2 = ans2[0];
    long long s1 = ans1[1] - ans1[0];
    long long s2 = ans2[1] - ans2[0];
    for (int i = 0; i <= 5e6; i++) {
        if (t1 == t2) {
            cout << t1 << endl;
            return 0;
        }
        if (t1 < t2) {
            t1 += s1;
        } else {
            t2 += s2;
        }
    }
    cout << "-1" << endl;
    return 0;
}


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
declare long long variables x and y
exgcd is a long long function with long long arguments a and b
    if b = 0
        assign 1 to x
        assign 0 to y
        return a
    end of the block
    declare long long d = exgcd(b, a % b)
    declare long long variable t = x
    change x to y
    set y to t - a / b * y
    return d
end of the block
define the main function
    create long longs m, h1, a1, x1, y1, h2, a2, x2 and y2
    declare long longs p1, p2, q1 and q2
    loop, reading m, h1, a1, x1, y1, h2, a2, x2 and y2 from the input
        change p1, p2, q1 and q2 to 0
        change i from 1 to 2 * m inclusive in a loop
            set h1 to (h1 * x1 + y1) % m
            if h1 is equal to a1
                if p1 = 0
                    assign i to p1
                else if q1 is equal to 0
                    assign i - p1 to q1
                    break the loop
                end of the block
            end of the block
        end of the block
        for i = 1 to 2 * m inclusive
            set h2 to (h2 * x2 + y2) % m
            if h2 = a2
                if p2 = 0
                    set p2 to i
                else if q2 = 0
                    assign i - p2 to q2
                    stop the loop
                end of the block
            end of the block
        end of the block
        declare long long d = exgcd(q1, -q2)
        create long long c = p2 - p1
        if d = 0
            print "-1" to stdout
            go to the start of the loop
        end of the block
        if c % d != 0
            print "-1" to stdout
            skip the rest of the loop
        end of the block
        if p1 = 0 or p2 is equal to 0
            print "-1" to stdout
            skip the rest of the loop
        end of the block
        if q2 = 0 and q1 = 0 and p1 != p2
            print "-1" to stdout
            skip the rest of the loop
        end of the block
        if (q2 = 0 and p2 - p1 < 0) is true or (q1 = 0 and p1 - p2 < 0) is true
            print "-1" to standard output
            skip the rest of the loop
        end of the block
        declare long long variable k = c / d
        multiply x by k
        multiply y by k
        if d is less than 0, invert the sign of d
        if x < 0 or y < 0
            start infinite loop
                add q2 / d to x
                add q1 / d to y
                if x >= 0 and y >= 0, stop the loop
            end of the block
        end of the block
        if x > 0 and y > 0
            start infinite loop
                subtract q2 / d from x
                decrease y by q1 / d
                if x < 0 or y < 0
                    add q2 / d to x
                    add q1 / d to y
                    break
                end of the block
            end of the block
        end of the block
        create long long ans = x * q1 + p1
        print ans
    end of the block
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
x, y = long long integers
declare exgcd that takes two arguments, long long integers a and b
    if b is 0
        set x to 1
        set y to 0
        return a
    end of the block
    d = long long integer set to exgcd of b and a modulo b
    t = long long integer set to x
    set x to y
    set y to t - a / b * y
    return d
end of the block
define the main function
    m, h1, a1, x1, y1, h2, a2, x2, y2 = long long integers
    p1, p2, q1, q2 = long long integers
    while reading m, h1, a1, x1, y1, h2, a2, x2, and y2
        set p1, p2, q1, q2 to 0
        for i = 1 to 2 * m inclusive
            set h1 to h1 * x1 + y1 modulo m
            if h1 is a1
                if p1 is 0
                    set p1 to i
                else if q1 is 0
                    set q1 to i - p1
                    break
                end of the block
            end of the block
        end of the block
        for i =1 to 2 * m inclusive
            set h2 to h2 * x2 + y2 modulo m
            if h2 is a2
                if p2 is 0
                    set p2 to i
                else if q2 is 0
                    set q2 to i - p2
                    break
                end of the block
            end of the block
        end of the block
        d = long long integer set to exgcd of q1 and -q2
        c = long long integer set to p2 - p1
        if d is 0
            puts "-1"
            continue
        end of the block
        if c modulo d
            puts "-1"
            continue
        end of the block
        if p1 is 0 or p2 is 0
            puts "-1"
            continue
        end of the block
        if q2 is 0 and q1 is 0 and p1 != p2
            puts "-1"
            continue
        end of the block
        if q2 is 0 and p2 - p1 < 0 or q1 is 0 and p1 - p2 < 0
            puts "-1"
            continue
        end of the block
        k = long long integer set to c / d
        multiply x by k
        multiply y by k
        if d < 0, set d to -d
        if x < 0 or y < 0
            while 1 exists
                add q2 / d to x
                add q1 / d to y
                if x >= 0 and y >= 0, break
            end of the block
        end of the block
        if x > 0 and y > 0
            while 1 exists
                subtract q2 / d from x
                subtract q1 / d from y
                if x < 0 or y < 0
                    add q2 / d to x
                    add q1 / d to y
                    break
                end of the block
            end of the block
        end of the block
        ans = long long integer set to x * q1 + p1
        print ans
    end of the block
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
n = long long and h, a, x, y = long long array of size 2 each
vis = two dimensional long long array of sizes 1000001 and 2
b = long long vector array of size 2
ans = two dimensional long long array of sizes 2 and 2
val = two dimensional long long array of sizes 1000001 and 2
in function pass taking a long long i and returning a long long
    set vis[h[i]][i] to 1
    set val[h[i]][i] to 1
    va = long long with va = 2
    append h[i] to b[i]
    loop while vis[h[i]][i] is 1
        set h[i] to (x[i] * h[i] + y[i]) mod m
        append h[i] to b[i]
        if vis[h[i]][i] is 0
            increment vis[h[i]][i]
            set val[h[i]][i] to va
            increment va
        else
            set ans[i][0] to val[h[i]][i] - 1
            set ans[i][1] to va - val[h[i]][i]
            return to indicate successful execution
        end of the block
    end of the block
end of the block
define the main function
    read m then h[0] then a[0] then x[0] then y[0] then h[1] then a[1] then x[1] then y[1]
    call pass of 0
    call pass of 1
    if vis[a[0]][0] or vis[a[1]][1] is 0
        print -1
        return to indicate successful execution
    end of the block
    va1, va2 = long long with va1 = val[a[0]][0] and va2 = val[a[1]][1]
    cy1, cy2 = long long with cy1 = ans[0][1] and cy2 = ans[1][1]
    if val[a[0]][0] is val[a[1]][1]
        print val[a[0]][0] - 1
        return to indicate successful execution
    end of the block
    if val[a[0]][0] is less or equal to ans[0][0] and val[a[1]][1] is less or equal to ans[1][0]
        print -1
        return to indicate successful execution
    else if val[a[0]][0] is less or equal to ans[0][0] or val[a[1]][1] is less or equal to ans[1][0]
        mo = long long with mo = absolute of val[a[1]][1] - val[a[0]][0]
        if val[a[0]][0] is greater than val[a[1]][1] and val[a[0]][0] is less or equal to ans[0][0]
            if mo is a multiple of ans[1][1]
                print val[a[0]][0] - 1
            else
                print -1
        else if val[a[0]][0] is less than val[a[1]][1] and val[a[1]][1] is less or equal to ans[1][0]
            if mo is a multiple of ans[0][1]
                print val[a[1]][1] - 1
            else
                print -1
        else
            print -1
        end of the block
        return to indicate successful execution
    end of the block
    if absolute of va1 - va2 mod __gcd of cy1 and cy2 is not 0
        print -1
        return to indicate successful execution
    end of the block
    for i = 0 to 1000001
        va = long long with va = va1 - va2 + i * cy1
        if va is a multiple of cy2 and va is greater or equal to 0
            print va1 + i * cy1 - 1
            return to indicate successful execution
        end of the block
    end of the block
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
create long long variables m, h1, a1, x1, h2, a2, x2, y2, y, p1, p2, t1 and t2
define the main function
    read input to m, h1, a1, x1, y, h2, a2, x2 and y2
    for i from 1 to 1e7 inclusive
        declare long long ans1 = (((h1 * x1 * 1LL) + y) % m)
        declare long long ans2 = (((h2 * x2 * 1LL) + y2) % m)
        change h1 to ans1 and h2 to ans2
        if a1 is equal to ans1
            if p1 = 0
                assign i to p1
            else if t1 = 0
                change t1 to i - p1
        end of the block
        if a2 is equal to ans2
            if p2 is false
                change p2 to i
            else if t2 = 0
                change t2 to i - p2
        end of the block
    end of the block
    if p1 is false or p2 is false, return !(cout<< -1 << endl)
    for i from 1 to 1e7 inclusive
        if p1 is equal to p2, return !(cout << p1 << endl)
        if p1 is less than p2
            increase p1 by t1
        else
            add t2 to p2
    end of the block
    print -1
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
create integer k
define the main function
    read k
    print "+------------------------+\n"
    print "|"
    for i = 0 to 11 exclusive
        if i is 0
            if i + 1 is less than or equal to k
                print "O."
            else
                print "#."
        else
            if i * 3 + 2 is less than or equal to k
                print "O."
            else
                print "#."
        end of the block
    end of the block
    print "|D|)\n"
    print "|"
    for i = 0 to 11 exclusive
        if i is 0
            if i + 2 is less than or equal to k
                print "O."
            else
                print "#."
        else
            if i * 3 + 3 is less than or equal to k
                print "O."
            else
                print "#."
        end of the block
    end of the block
    print "|.|\n"
    print "|"
    for i = 0 to 11 exclusive
        if 3 is less than or equal to k and i is 0
            print "O."
        else if i is 0
            print "#."
        else
            print ".."
    end of the block
    print "..|\n"
    print "|"
    for i = 0 to 11 exclusive
        if i is 0
            if i + 4 is less than or equal to k
                print "O."
            else
                print "#."
        else
            if i * 3 + 4 is less than or equal to k
                print "O."
            else
                print "#."
        end of the block
    end of the block
    print "|.|)\n"
    print "+------------------------+\n"
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
let Pi be a constant double with value is equal to arc cosine of (-1.0)
define the main function
    let k be a integer
    read k
    print +------------------------+ and newline
    print |
    if (k is greater than 0)
        print O.
    else do the following
        print #.
    let c be a integer with value c is equal to (k - 4) / 3
    if ((k - 4) modulus 3 is greater than 0), increase c by 1
    for ( i =0 to 10 exclusive )
        if (i is less than c)
            print O.
        else do the following
            print #.
    end of the block
    print |D| and newline
    print |
    if (k is greater than 1)
        print O.
    else do the following
        print #.
    let the value of c is equal to (k - 4) / 3
    if ((k - 4) modulus 3 is greater than 1), increase c value by 1
    for ( i = 0 to 10 exclusive )
        if (i is less than c)
            print O.
        else, do the following
            print #.
    end of the block
    print |.| and newline
    print |
    if (k is greater than 2)
        print O
    else do the following
        print #
    print .......................| and newline
    print |
    if (k is greater than 3)
        print O.
    else do the following
        print #.
    let the value of c is equal to (k - 4) / 3
    for ( i =0 to 10 exclusive )
        if (i is less than c)
            print O.
        else do the following
            print #.
    end of the block
    print |.| and newline
    print +------------------------+ and newline
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create int n
    read n
    print +------------------------+
    print |
    if n >= 1
        print O.
    else
        print #.
    for a=1 to 10 inclusive
        if n >= 3* a +2
            print O.
        else
            print #.
    print |D| and a newline
    print |
    if n >= 2
        print O.
    otherwise
        print #.
    for a=1 to 10 inclusive
        if n >= 3 * a + 3
            print O.
        otherwise
            print #.
    print |.| and a newline
    print |
    if n >= 3
        print O.
    else
        print #.
    print ......................| and a newline
    print |
    if n >= 4
        print O.
    else
        print #.
    for a=1 to 10 inclusive
        if n >= 3*a+4
            print O.
        else
            print #.
    print |.|) and a newline
    print +------------------------+ and a newline
    return to indicate successful execution
end of the block

[CODE]:


[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    let p be an int
    read p
    if p is equal to 0
        print +------------------------+
        print |#.#.#.#.#.#.#.#.#.#.#.|D|)
        print |#.#.#.#.#.#.#.#.#.#.#.|.|
        print |#.......................|
        print |#.#.#.#.#.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 1
        print +------------------------+ and a newline
        print |O.#.#.#.#.#.#.#.#.#.#.|D|) and a newline
        print |#.#.#.#.#.#.#.#.#.#.#.|.| and a newline
        print |#.......................|
        print |#.#.#.#.#.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 2
        print +------------------------+
        print |O.#.#.#.#.#.#.#.#.#.#.|D|) and a newline
        print |O.#.#.#.#.#.#.#.#.#.#.|.|
        print |#.......................|
        print |#.#.#.#.#.#.#.#.#.#.#.|.|)
        print +------------------------+ and a newline
    end of the block
    if p is equal to 3
        print +------------------------+
        print |O.#.#.#.#.#.#.#.#.#.#.|D|)
        print |O.#.#.#.#.#.#.#.#.#.#.|.| and a newline
        print |O.......................| and a newline
        print |#.#.#.#.#.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 4
        print +------------------------+
        print |O.#.#.#.#.#.#.#.#.#.#.|D|)
        print |O.#.#.#.#.#.#.#.#.#.#.|.| and a newline
        print |O.......................|
        print |O.#.#.#.#.#.#.#.#.#.#.|.|) and a newline
        print +------------------------+
    end of the block
    if p is equal to 5
        print +------------------------+
        print |O.O.#.#.#.#.#.#.#.#.#.|D|)
        print |O.#.#.#.#.#.#.#.#.#.#.|.|
        print |O.......................| and a newline
        print |O.#.#.#.#.#.#.#.#.#.#.|.|)
        print +------------------------+ and a newline
    end of the block
    if p is 6
        print +------------------------+
        print |O.O.#.#.#.#.#.#.#.#.#.|D|)
        print |O.O.#.#.#.#.#.#.#.#.#.|.|
        print |O.......................|
        print |O.#.#.#.#.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 7
        print +------------------------+
        print |O.O.#.#.#.#.#.#.#.#.#.|D|)
        print |O.O.#.#.#.#.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.#.#.#.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 8
        print +------------------------+
        print |O.O.O.#.#.#.#.#.#.#.#.|D|)
        print |O.O.#.#.#.#.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.#.#.#.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 9
        print +------------------------+
        print |O.O.O.#.#.#.#.#.#.#.#.|D|)
        print |O.O.O.#.#.#.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.#.#.#.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 10
        print +------------------------+
        print |O.O.O.#.#.#.#.#.#.#.#.|D|)
        print |O.O.O.#.#.#.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.#.#.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 11
        print +------------------------+
        print |O.O.O.O.#.#.#.#.#.#.#.|D|)
        print |O.O.O.#.#.#.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.#.#.#.#.#.#.#.#.|.|) and a newline
        print +------------------------+
    end of the block
    if p is 12
        print +------------------------+
        print |O.O.O.O.#.#.#.#.#.#.#.|D|)
        print |O.O.O.O.#.#.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.#.#.#.#.#.#.#.#.|.|)
        print +------------------------+ and a newline
    end of the block
    if p is 13
        print +------------------------+
        print |O.O.O.O.#.#.#.#.#.#.#.|D|)
        print |O.O.O.O.#.#.#.#.#.#.#.|.| and a newline
        print |O.......................|
        print |O.O.O.O.#.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 14
        print +------------------------+
        print |O.O.O.O.O.#.#.#.#.#.#.|D|)
        print |O.O.O.O.#.#.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.#.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 15
        print +------------------------+ and a newline
        print |O.O.O.O.O.#.#.#.#.#.#.|D|)
        print |O.O.O.O.O.#.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.#.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 16
        print +------------------------+
        print |O.O.O.O.O.#.#.#.#.#.#.|D|)
        print |O.O.O.O.O.#.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 17
        print +------------------------+ and a newline
        print |O.O.O.O.O.O.#.#.#.#.#.|D|)
        print |O.O.O.O.O.#.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 18
        print +------------------------+
        print |O.O.O.O.O.O.#.#.#.#.#.|D|)
        print |O.O.O.O.O.O.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.#.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 19
        print +------------------------+
        print |O.O.O.O.O.O.#.#.#.#.#.|D|)
        print |O.O.O.O.O.O.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 20
        print +------------------------+
        print |O.O.O.O.O.O.O.#.#.#.#.|D|)
        print |O.O.O.O.O.O.#.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 21
        print +------------------------+
        print |O.O.O.O.O.O.O.#.#.#.#.|D|)
        print |O.O.O.O.O.O.O.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.#.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 22
        print +------------------------+
        print |O.O.O.O.O.O.O.#.#.#.#.|D|)
        print |O.O.O.O.O.O.O.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 23
        print +------------------------+
        print |O.O.O.O.O.O.O.O.#.#.#.|D|)
        print |O.O.O.O.O.O.O.#.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 24
        print +------------------------+
        print |O.O.O.O.O.O.O.O.#.#.#.|D|)
        print |O.O.O.O.O.O.O.O.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.#.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 25
        print +------------------------+
        print |O.O.O.O.O.O.O.O.#.#.#.|D|)
        print |O.O.O.O.O.O.O.O.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.O.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 26
        print +------------------------+ and a newline
        print |O.O.O.O.O.O.O.O.O.#.#.|D|)
        print |O.O.O.O.O.O.O.O.#.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.O.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 27
        print +------------------------+
        print |O.O.O.O.O.O.O.O.O.#.#.|D|)
        print |O.O.O.O.O.O.O.O.O.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.O.#.#.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 28
        print +------------------------+
        print |O.O.O.O.O.O.O.O.O.#.#.|D|)
        print |O.O.O.O.O.O.O.O.O.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.O.O.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 29
        print +------------------------+
        print |O.O.O.O.O.O.O.O.O.O.#.|D|)
        print |O.O.O.O.O.O.O.O.O.#.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.O.O.#.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 30
        print +------------------------+
        print |O.O.O.O.O.O.O.O.O.O.#.|D|)
        print |O.O.O.O.O.O.O.O.O.O.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.O.O.#.#.|.|)
        print +------------------------+
    end of the block
    if p is 31
        print +------------------------+
        print |O.O.O.O.O.O.O.O.O.O.#.|D|)
        print |O.O.O.O.O.O.O.O.O.O.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.O.O.O.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 32
        print +------------------------+
        print |O.O.O.O.O.O.O.O.O.O.O.|D|)
        print |O.O.O.O.O.O.O.O.O.O.#.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.O.O.O.#.|.|)
        print +------------------------+
    end of the block
    if p is 33
        print +------------------------+
        print |O.O.O.O.O.O.O.O.O.O.O.|D|)
        print |O.O.O.O.O.O.O.O.O.O.O.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.O.O.O.#.|.|)
        print +------------------------+
    end of the block
    if p is equal to 34
        print +------------------------+
        print |O.O.O.O.O.O.O.O.O.O.O.|D|)
        print |O.O.O.O.O.O.O.O.O.O.O.|.|
        print |O.......................|
        print |O.O.O.O.O.O.O.O.O.O.O.|.|)
        print +------------------------+
    end of the block
    return to indicate successful execution
end of the block

[CODE]: