1 for (int c1 = 0; c1 <= m; c1 += 1)
2   S1(1, c1);
3 for (int c0 = 2; c0 <= n; c0 += 1) {
4   for (int c1 = 0; c1 < c0 - 1; c1 += 1)
5     S2(c0, c1);
6   for (int c1 = c0 - 1; c1 <= n; c1 += 1) {
7     S1(c0, c1);
8     S2(c0, c1);
9   }
10   for (int c1 = n + 1; c1 <= m; c1 += 1)
11     S1(c0, c1);
12 }
13 for (int c0 = n + 1; c0 <= m + 1; c0 += 1)
14   for (int c1 = c0 - 1; c1 <= m; c1 += 1)
15     S1(c0, c1);
16