QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#119225#5575. Knight's Tour Reduxhos.lyric🐇AC ✓12ms4260kbC++143.6kb2023-07-05 05:59:142023-07-05 05:59:16

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-05 05:59:16]
  • Judged
  • Verdict: AC
  • Time: 12ms
  • Memory: 4260kb
  • [2023-07-05 05:59:14]
  • Submitted

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


constexpr char DATA[3][12][12] = {
{
"a......",
"...b...",
"..e....",
".....f.",
"....c..",
".d.....",
"......g",
},
{
"a........",
"...b.....",
"......c..",
".f.......",
"....e....",
".......d.",
"..g......",
".....h...",
"........i",
},
{
"a..........",
"...b.......",
"......c....",
".........d.",
"..g........",
".....f.....",
"........e..",
".h.........",
"....i......",
".......j...",
"..........k",
},
};

vector<pair<int, int>> solve(int N) {
  vector<pair<int, int>> ans;
  auto add = [&](int x, int y) -> void {
    ans.emplace_back(x, y);
  };
  
  if (N == 1) {
    add(0, 0);
  } else if (N <= 4) {
    return {};
  } else {
    int n = (N == 5) ? 5 : (6 + (N - 6) % 6);
    {
      const int h = (n == 5) ? 0 : ((n - 6) / 2);
      const int l = (n == 5 || n % 2 == 0) ? 1 : 0;
      const int r = l + n;
      vector<pair<char, pair<int, int>>> ps;
      for (int x = l; x < r; ++x) for (int y = l; y < r; ++y) if (DATA[h][x][y] != '.') {
        ps.emplace_back(DATA[h][x][y], make_pair(x - l, y - l));
      }
      sort(ps.begin(), ps.end());
      for (const auto &p : ps) {
        add(p.second.first, p.second.second);
      }
    }
    {
      const int h = 0;
      const int l = 1;
      const int r = 7;
      vector<pair<char, pair<int, int>>> ps;
      for (int x = l; x < r; ++x) for (int y = l; y < r; ++y) if (DATA[h][x][y] != '.') {
        ps.emplace_back(DATA[h][x][y], make_pair(x - l, y - l));
      }
      sort(ps.begin(), ps.end());
      for (; n < N; n += 6) {
        for (const auto &p : ps) {
          add(n + p.second.first, n + p.second.second);
        }
      }
    }
  }
  
  return ans;
}

int main() {
#ifdef LOCAL
  for (int N = 1; N <= 26; ++N) {
    cerr << N << endl;
    const auto res = solve(N);
    if (!res.empty()) {
      assert((int)res.size() == N);
      vector<string> a(N, string(N, '.'));
      for (int i = 0; i < N; ++i) {
        a[res[i].first][res[i].second] = 'a' + i;
      }
      for (int x = 0; x < N; ++x) {
        cerr << a[x] << endl;
      }
    }
  }
#endif
  
  int N;
  for (; ~scanf("%d", &N); ) {
    const auto ans = solve(N);
    if (!ans.empty()) {
      puts("POSSIBLE");
      for (const auto &p : ans) {
        printf("%d %d\n", p.first + 1, p.second + 1);
      }
    } else {
      puts("IMPOSSIBLE");
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3692kb

input:

1

output:

POSSIBLE
1 1

result:

ok answer = 1

Test #2:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

2

output:

IMPOSSIBLE

result:

ok answer = 0

Test #3:

score: 0
Accepted
time: 1ms
memory: 3452kb

input:

3

output:

IMPOSSIBLE

result:

ok answer = 0

Test #4:

score: 0
Accepted
time: 1ms
memory: 3384kb

input:

4

output:

IMPOSSIBLE

result:

ok answer = 0

Test #5:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

5

output:

POSSIBLE
1 3
4 4
5 1
2 2
3 5

result:

ok answer = 1

Test #6:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

6

output:

POSSIBLE
1 3
4 4
5 1
2 2
3 5
6 6

result:

ok answer = 1

Test #7:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

7

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7

result:

ok answer = 1

Test #8:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

8

output:

POSSIBLE
1 3
2 6
5 7
4 4
3 1
6 2
7 5
8 8

result:

ok answer = 1

Test #9:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

9

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9

result:

ok answer = 1

Test #10:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

10

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10

result:

ok answer = 1

Test #11:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

11

output:

POSSIBLE
1 1
2 4
3 7
4 10
7 9
6 6
5 3
8 2
9 5
10 8
11 11

result:

ok answer = 1

Test #12:

score: 0
Accepted
time: 1ms
memory: 3680kb

input:

12

output:

POSSIBLE
1 3
4 4
5 1
2 2
3 5
6 6
7 9
10 10
11 7
8 8
9 11
12 12

result:

ok answer = 1

Test #13:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

13

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12
13 13

result:

ok answer = 1

Test #14:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

14

output:

POSSIBLE
1 3
2 6
5 7
4 4
3 1
6 2
7 5
8 8
9 11
12 12
13 9
10 10
11 13
14 14

result:

ok answer = 1

Test #15:

score: 0
Accepted
time: 1ms
memory: 3732kb

input:

15

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9
10 12
13 13
14 10
11 11
12 14
15 15

result:

ok answer = 1

Test #16:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

16

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16

result:

ok answer = 1

Test #17:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

17

output:

POSSIBLE
1 1
2 4
3 7
4 10
7 9
6 6
5 3
8 2
9 5
10 8
11 11
12 14
15 15
16 12
13 13
14 16
17 17

result:

ok answer = 1

Test #18:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

18

output:

POSSIBLE
1 3
4 4
5 1
2 2
3 5
6 6
7 9
10 10
11 7
8 8
9 11
12 12
13 15
16 16
17 13
14 14
15 17
18 18

result:

ok answer = 1

Test #19:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

19

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12
13 13
14 16
17 17
18 14
15 15
16 18
19 19

result:

ok answer = 1

Test #20:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

20

output:

POSSIBLE
1 3
2 6
5 7
4 4
3 1
6 2
7 5
8 8
9 11
12 12
13 9
10 10
11 13
14 14
15 17
18 18
19 15
16 16
17 19
20 20

result:

ok answer = 1

Test #21:

score: 0
Accepted
time: 4ms
memory: 4084kb

input:

99990

output:

POSSIBLE
1 3
4 4
5 1
2 2
3 5
6 6
7 9
10 10
11 7
8 8
9 11
12 12
13 15
16 16
17 13
14 14
15 17
18 18
19 21
22 22
23 19
20 20
21 23
24 24
25 27
28 28
29 25
26 26
27 29
30 30
31 33
34 34
35 31
32 32
33 35
36 36
37 39
40 40
41 37
38 38
39 41
42 42
43 45
46 46
47 43
44 44
45 47
48 48
49 51
52 52
53 49
50 ...

result:

ok answer = 1

Test #22:

score: 0
Accepted
time: 12ms
memory: 4252kb

input:

99991

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12
13 13
14 16
17 17
18 14
15 15
16 18
19 19
20 22
23 23
24 20
21 21
22 24
25 25
26 28
29 29
30 26
27 27
28 30
31 31
32 34
35 35
36 32
33 33
34 36
37 37
38 40
41 41
42 38
39 39
40 42
43 43
44 46
47 47
48 44
45 45
46 48
49 49
50 52
53 53
54 ...

result:

ok answer = 1

Test #23:

score: 0
Accepted
time: 9ms
memory: 4068kb

input:

99992

output:

POSSIBLE
1 3
2 6
5 7
4 4
3 1
6 2
7 5
8 8
9 11
12 12
13 9
10 10
11 13
14 14
15 17
18 18
19 15
16 16
17 19
20 20
21 23
24 24
25 21
22 22
23 25
26 26
27 29
30 30
31 27
28 28
29 31
32 32
33 35
36 36
37 33
34 34
35 37
38 38
39 41
42 42
43 39
40 40
41 43
44 44
45 47
48 48
49 45
46 46
47 49
50 50
51 53
54 ...

result:

ok answer = 1

Test #24:

score: 0
Accepted
time: 5ms
memory: 4260kb

input:

99993

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9
10 12
13 13
14 10
11 11
12 14
15 15
16 18
19 19
20 16
17 17
18 20
21 21
22 24
25 25
26 22
23 23
24 26
27 27
28 30
31 31
32 28
29 29
30 32
33 33
34 36
37 37
38 34
35 35
36 38
39 39
40 42
43 43
44 40
41 41
42 44
45 45
46 48
49 49
50 46
47 47
48 50
51 51
52 ...

result:

ok answer = 1

Test #25:

score: 0
Accepted
time: 5ms
memory: 4216kb

input:

99994

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16
17 19
20 20
21 17
18 18
19 21
22 22
23 25
26 26
27 23
24 24
25 27
28 28
29 31
32 32
33 29
30 30
31 33
34 34
35 37
38 38
39 35
36 36
37 39
40 40
41 43
44 44
45 41
42 42
43 45
46 46
47 49
50 50
51 47
48 48
49 51
52 ...

result:

ok answer = 1

Test #26:

score: 0
Accepted
time: 12ms
memory: 4208kb

input:

99995

output:

POSSIBLE
1 1
2 4
3 7
4 10
7 9
6 6
5 3
8 2
9 5
10 8
11 11
12 14
15 15
16 12
13 13
14 16
17 17
18 20
21 21
22 18
19 19
20 22
23 23
24 26
27 27
28 24
25 25
26 28
29 29
30 32
33 33
34 30
31 31
32 34
35 35
36 38
39 39
40 36
37 37
38 40
41 41
42 44
45 45
46 42
43 43
44 46
47 47
48 50
51 51
52 48
49 49
50 ...

result:

ok answer = 1

Test #27:

score: 0
Accepted
time: 10ms
memory: 4128kb

input:

99996

output:

POSSIBLE
1 3
4 4
5 1
2 2
3 5
6 6
7 9
10 10
11 7
8 8
9 11
12 12
13 15
16 16
17 13
14 14
15 17
18 18
19 21
22 22
23 19
20 20
21 23
24 24
25 27
28 28
29 25
26 26
27 29
30 30
31 33
34 34
35 31
32 32
33 35
36 36
37 39
40 40
41 37
38 38
39 41
42 42
43 45
46 46
47 43
44 44
45 47
48 48
49 51
52 52
53 49
50 ...

result:

ok answer = 1

Test #28:

score: 0
Accepted
time: 9ms
memory: 4168kb

input:

99997

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12
13 13
14 16
17 17
18 14
15 15
16 18
19 19
20 22
23 23
24 20
21 21
22 24
25 25
26 28
29 29
30 26
27 27
28 30
31 31
32 34
35 35
36 32
33 33
34 36
37 37
38 40
41 41
42 38
39 39
40 42
43 43
44 46
47 47
48 44
45 45
46 48
49 49
50 52
53 53
54 ...

result:

ok answer = 1

Test #29:

score: 0
Accepted
time: 12ms
memory: 4160kb

input:

99998

output:

POSSIBLE
1 3
2 6
5 7
4 4
3 1
6 2
7 5
8 8
9 11
12 12
13 9
10 10
11 13
14 14
15 17
18 18
19 15
16 16
17 19
20 20
21 23
24 24
25 21
22 22
23 25
26 26
27 29
30 30
31 27
28 28
29 31
32 32
33 35
36 36
37 33
34 34
35 37
38 38
39 41
42 42
43 39
40 40
41 43
44 44
45 47
48 48
49 45
46 46
47 49
50 50
51 53
54 ...

result:

ok answer = 1

Test #30:

score: 0
Accepted
time: 7ms
memory: 4072kb

input:

99999

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9
10 12
13 13
14 10
11 11
12 14
15 15
16 18
19 19
20 16
17 17
18 20
21 21
22 24
25 25
26 22
23 23
24 26
27 27
28 30
31 31
32 28
29 29
30 32
33 33
34 36
37 37
38 34
35 35
36 38
39 39
40 42
43 43
44 40
41 41
42 44
45 45
46 48
49 49
50 46
47 47
48 50
51 51
52 ...

result:

ok answer = 1

Test #31:

score: 0
Accepted
time: 12ms
memory: 4064kb

input:

100000

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16
17 19
20 20
21 17
18 18
19 21
22 22
23 25
26 26
27 23
24 24
25 27
28 28
29 31
32 32
33 29
30 30
31 33
34 34
35 37
38 38
39 35
36 36
37 39
40 40
41 43
44 44
45 41
42 42
43 45
46 46
47 49
50 50
51 47
48 48
49 51
52 ...

result:

ok answer = 1

Test #32:

score: 0
Accepted
time: 2ms
memory: 4176kb

input:

74615

output:

POSSIBLE
1 1
2 4
3 7
4 10
7 9
6 6
5 3
8 2
9 5
10 8
11 11
12 14
15 15
16 12
13 13
14 16
17 17
18 20
21 21
22 18
19 19
20 22
23 23
24 26
27 27
28 24
25 25
26 28
29 29
30 32
33 33
34 30
31 31
32 34
35 35
36 38
39 39
40 36
37 37
38 40
41 41
42 44
45 45
46 42
43 43
44 46
47 47
48 50
51 51
52 48
49 49
50 ...

result:

ok answer = 1

Test #33:

score: 0
Accepted
time: 2ms
memory: 3804kb

input:

25027

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12
13 13
14 16
17 17
18 14
15 15
16 18
19 19
20 22
23 23
24 20
21 21
22 24
25 25
26 28
29 29
30 26
27 27
28 30
31 31
32 34
35 35
36 32
33 33
34 36
37 37
38 40
41 41
42 38
39 39
40 42
43 43
44 46
47 47
48 44
45 45
46 48
49 49
50 52
53 53
54 ...

result:

ok answer = 1

Test #34:

score: 0
Accepted
time: 2ms
memory: 3772kb

input:

40852

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16
17 19
20 20
21 17
18 18
19 21
22 22
23 25
26 26
27 23
24 24
25 27
28 28
29 31
32 32
33 29
30 30
31 33
34 34
35 37
38 38
39 35
36 36
37 39
40 40
41 43
44 44
45 41
42 42
43 45
46 46
47 49
50 50
51 47
48 48
49 51
52 ...

result:

ok answer = 1

Test #35:

score: 0
Accepted
time: 4ms
memory: 3816kb

input:

31411

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12
13 13
14 16
17 17
18 14
15 15
16 18
19 19
20 22
23 23
24 20
21 21
22 24
25 25
26 28
29 29
30 26
27 27
28 30
31 31
32 34
35 35
36 32
33 33
34 36
37 37
38 40
41 41
42 38
39 39
40 42
43 43
44 46
47 47
48 44
45 45
46 48
49 49
50 52
53 53
54 ...

result:

ok answer = 1

Test #36:

score: 0
Accepted
time: 5ms
memory: 3808kb

input:

37332

output:

POSSIBLE
1 3
4 4
5 1
2 2
3 5
6 6
7 9
10 10
11 7
8 8
9 11
12 12
13 15
16 16
17 13
14 14
15 17
18 18
19 21
22 22
23 19
20 20
21 23
24 24
25 27
28 28
29 25
26 26
27 29
30 30
31 33
34 34
35 31
32 32
33 35
36 36
37 39
40 40
41 37
38 38
39 41
42 42
43 45
46 46
47 43
44 44
45 47
48 48
49 51
52 52
53 49
50 ...

result:

ok answer = 1

Test #37:

score: 0
Accepted
time: 7ms
memory: 4084kb

input:

80435

output:

POSSIBLE
1 1
2 4
3 7
4 10
7 9
6 6
5 3
8 2
9 5
10 8
11 11
12 14
15 15
16 12
13 13
14 16
17 17
18 20
21 21
22 18
19 19
20 22
23 23
24 26
27 27
28 24
25 25
26 28
29 29
30 32
33 33
34 30
31 31
32 34
35 35
36 38
39 39
40 36
37 37
38 40
41 41
42 44
45 45
46 42
43 43
44 46
47 47
48 50
51 51
52 48
49 49
50 ...

result:

ok answer = 1

Test #38:

score: 0
Accepted
time: 5ms
memory: 4132kb

input:

90457

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12
13 13
14 16
17 17
18 14
15 15
16 18
19 19
20 22
23 23
24 20
21 21
22 24
25 25
26 28
29 29
30 26
27 27
28 30
31 31
32 34
35 35
36 32
33 33
34 36
37 37
38 40
41 41
42 38
39 39
40 42
43 43
44 46
47 47
48 44
45 45
46 48
49 49
50 52
53 53
54 ...

result:

ok answer = 1

Test #39:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

1796

output:

POSSIBLE
1 3
2 6
5 7
4 4
3 1
6 2
7 5
8 8
9 11
12 12
13 9
10 10
11 13
14 14
15 17
18 18
19 15
16 16
17 19
20 20
21 23
24 24
25 21
22 22
23 25
26 26
27 29
30 30
31 27
28 28
29 31
32 32
33 35
36 36
37 33
34 34
35 37
38 38
39 41
42 42
43 39
40 40
41 43
44 44
45 47
48 48
49 45
46 46
47 49
50 50
51 53
54 ...

result:

ok answer = 1

Test #40:

score: 0
Accepted
time: 3ms
memory: 3872kb

input:

55809

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9
10 12
13 13
14 10
11 11
12 14
15 15
16 18
19 19
20 16
17 17
18 20
21 21
22 24
25 25
26 22
23 23
24 26
27 27
28 30
31 31
32 28
29 29
30 32
33 33
34 36
37 37
38 34
35 35
36 38
39 39
40 42
43 43
44 40
41 41
42 44
45 45
46 48
49 49
50 46
47 47
48 50
51 51
52 ...

result:

ok answer = 1

Test #41:

score: 0
Accepted
time: 2ms
memory: 4196kb

input:

97013

output:

POSSIBLE
1 1
2 4
3 7
4 10
7 9
6 6
5 3
8 2
9 5
10 8
11 11
12 14
15 15
16 12
13 13
14 16
17 17
18 20
21 21
22 18
19 19
20 22
23 23
24 26
27 27
28 24
25 25
26 28
29 29
30 32
33 33
34 30
31 31
32 34
35 35
36 38
39 39
40 36
37 37
38 40
41 41
42 44
45 45
46 42
43 43
44 46
47 47
48 50
51 51
52 48
49 49
50 ...

result:

ok answer = 1

Test #42:

score: 0
Accepted
time: 9ms
memory: 4248kb

input:

77938

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16
17 19
20 20
21 17
18 18
19 21
22 22
23 25
26 26
27 23
24 24
25 27
28 28
29 31
32 32
33 29
30 30
31 33
34 34
35 37
38 38
39 35
36 36
37 39
40 40
41 43
44 44
45 41
42 42
43 45
46 46
47 49
50 50
51 47
48 48
49 51
52 ...

result:

ok answer = 1

Test #43:

score: 0
Accepted
time: 7ms
memory: 4208kb

input:

87884

output:

POSSIBLE
1 3
2 6
5 7
4 4
3 1
6 2
7 5
8 8
9 11
12 12
13 9
10 10
11 13
14 14
15 17
18 18
19 15
16 16
17 19
20 20
21 23
24 24
25 21
22 22
23 25
26 26
27 29
30 30
31 27
28 28
29 31
32 32
33 35
36 36
37 33
34 34
35 37
38 38
39 41
42 42
43 39
40 40
41 43
44 44
45 47
48 48
49 45
46 46
47 49
50 50
51 53
54 ...

result:

ok answer = 1

Test #44:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

61687

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12
13 13
14 16
17 17
18 14
15 15
16 18
19 19
20 22
23 23
24 20
21 21
22 24
25 25
26 28
29 29
30 26
27 27
28 30
31 31
32 34
35 35
36 32
33 33
34 36
37 37
38 40
41 41
42 38
39 39
40 42
43 43
44 46
47 47
48 44
45 45
46 48
49 49
50 52
53 53
54 ...

result:

ok answer = 1

Test #45:

score: 0
Accepted
time: 1ms
memory: 3828kb

input:

32567

output:

POSSIBLE
1 1
2 4
3 7
4 10
7 9
6 6
5 3
8 2
9 5
10 8
11 11
12 14
15 15
16 12
13 13
14 16
17 17
18 20
21 21
22 18
19 19
20 22
23 23
24 26
27 27
28 24
25 25
26 28
29 29
30 32
33 33
34 30
31 31
32 34
35 35
36 38
39 39
40 36
37 37
38 40
41 41
42 44
45 45
46 42
43 43
44 46
47 47
48 50
51 51
52 48
49 49
50 ...

result:

ok answer = 1

Test #46:

score: 0
Accepted
time: 7ms
memory: 3764kb

input:

53441

output:

POSSIBLE
1 1
2 4
3 7
4 10
7 9
6 6
5 3
8 2
9 5
10 8
11 11
12 14
15 15
16 12
13 13
14 16
17 17
18 20
21 21
22 18
19 19
20 22
23 23
24 26
27 27
28 24
25 25
26 28
29 29
30 32
33 33
34 30
31 31
32 34
35 35
36 38
39 39
40 36
37 37
38 40
41 41
42 44
45 45
46 42
43 43
44 46
47 47
48 50
51 51
52 48
49 49
50 ...

result:

ok answer = 1

Test #47:

score: 0
Accepted
time: 3ms
memory: 3712kb

input:

19197

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9
10 12
13 13
14 10
11 11
12 14
15 15
16 18
19 19
20 16
17 17
18 20
21 21
22 24
25 25
26 22
23 23
24 26
27 27
28 30
31 31
32 28
29 29
30 32
33 33
34 36
37 37
38 34
35 35
36 38
39 39
40 42
43 43
44 40
41 41
42 44
45 45
46 48
49 49
50 46
47 47
48 50
51 51
52 ...

result:

ok answer = 1

Test #48:

score: 0
Accepted
time: 6ms
memory: 4252kb

input:

77260

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16
17 19
20 20
21 17
18 18
19 21
22 22
23 25
26 26
27 23
24 24
25 27
28 28
29 31
32 32
33 29
30 30
31 33
34 34
35 37
38 38
39 35
36 36
37 39
40 40
41 43
44 44
45 41
42 42
43 45
46 46
47 49
50 50
51 47
48 48
49 51
52 ...

result:

ok answer = 1

Test #49:

score: 0
Accepted
time: 2ms
memory: 3756kb

input:

6699

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9
10 12
13 13
14 10
11 11
12 14
15 15
16 18
19 19
20 16
17 17
18 20
21 21
22 24
25 25
26 22
23 23
24 26
27 27
28 30
31 31
32 28
29 29
30 32
33 33
34 36
37 37
38 34
35 35
36 38
39 39
40 42
43 43
44 40
41 41
42 44
45 45
46 48
49 49
50 46
47 47
48 50
51 51
52 ...

result:

ok answer = 1

Test #50:

score: 0
Accepted
time: 5ms
memory: 4132kb

input:

72561

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9
10 12
13 13
14 10
11 11
12 14
15 15
16 18
19 19
20 16
17 17
18 20
21 21
22 24
25 25
26 22
23 23
24 26
27 27
28 30
31 31
32 28
29 29
30 32
33 33
34 36
37 37
38 34
35 35
36 38
39 39
40 42
43 43
44 40
41 41
42 44
45 45
46 48
49 49
50 46
47 47
48 50
51 51
52 ...

result:

ok answer = 1

Test #51:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

60412

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16
17 19
20 20
21 17
18 18
19 21
22 22
23 25
26 26
27 23
24 24
25 27
28 28
29 31
32 32
33 29
30 30
31 33
34 34
35 37
38 38
39 35
36 36
37 39
40 40
41 43
44 44
45 41
42 42
43 45
46 46
47 49
50 50
51 47
48 48
49 51
52 ...

result:

ok answer = 1

Test #52:

score: 0
Accepted
time: 9ms
memory: 4204kb

input:

78243

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9
10 12
13 13
14 10
11 11
12 14
15 15
16 18
19 19
20 16
17 17
18 20
21 21
22 24
25 25
26 22
23 23
24 26
27 27
28 30
31 31
32 28
29 29
30 32
33 33
34 36
37 37
38 34
35 35
36 38
39 39
40 42
43 43
44 40
41 41
42 44
45 45
46 48
49 49
50 46
47 47
48 50
51 51
52 ...

result:

ok answer = 1

Test #53:

score: 0
Accepted
time: 4ms
memory: 4132kb

input:

93055

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12
13 13
14 16
17 17
18 14
15 15
16 18
19 19
20 22
23 23
24 20
21 21
22 24
25 25
26 28
29 29
30 26
27 27
28 30
31 31
32 34
35 35
36 32
33 33
34 36
37 37
38 40
41 41
42 38
39 39
40 42
43 43
44 46
47 47
48 44
45 45
46 48
49 49
50 52
53 53
54 ...

result:

ok answer = 1

Test #54:

score: 0
Accepted
time: 10ms
memory: 4208kb

input:

72060

output:

POSSIBLE
1 3
4 4
5 1
2 2
3 5
6 6
7 9
10 10
11 7
8 8
9 11
12 12
13 15
16 16
17 13
14 14
15 17
18 18
19 21
22 22
23 19
20 20
21 23
24 24
25 27
28 28
29 25
26 26
27 29
30 30
31 33
34 34
35 31
32 32
33 35
36 36
37 39
40 40
41 37
38 38
39 41
42 42
43 45
46 46
47 43
44 44
45 47
48 48
49 51
52 52
53 49
50 ...

result:

ok answer = 1

Test #55:

score: 0
Accepted
time: 1ms
memory: 3768kb

input:

10561

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12
13 13
14 16
17 17
18 14
15 15
16 18
19 19
20 22
23 23
24 20
21 21
22 24
25 25
26 28
29 29
30 26
27 27
28 30
31 31
32 34
35 35
36 32
33 33
34 36
37 37
38 40
41 41
42 38
39 39
40 42
43 43
44 46
47 47
48 44
45 45
46 48
49 49
50 52
53 53
54 ...

result:

ok answer = 1

Test #56:

score: 0
Accepted
time: 6ms
memory: 3768kb

input:

56368

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16
17 19
20 20
21 17
18 18
19 21
22 22
23 25
26 26
27 23
24 24
25 27
28 28
29 31
32 32
33 29
30 30
31 33
34 34
35 37
38 38
39 35
36 36
37 39
40 40
41 43
44 44
45 41
42 42
43 45
46 46
47 49
50 50
51 47
48 48
49 51
52 ...

result:

ok answer = 1

Test #57:

score: 0
Accepted
time: 6ms
memory: 3868kb

input:

44898

output:

POSSIBLE
1 3
4 4
5 1
2 2
3 5
6 6
7 9
10 10
11 7
8 8
9 11
12 12
13 15
16 16
17 13
14 14
15 17
18 18
19 21
22 22
23 19
20 20
21 23
24 24
25 27
28 28
29 25
26 26
27 29
30 30
31 33
34 34
35 31
32 32
33 35
36 36
37 39
40 40
41 37
38 38
39 41
42 42
43 45
46 46
47 43
44 44
45 47
48 48
49 51
52 52
53 49
50 ...

result:

ok answer = 1

Test #58:

score: 0
Accepted
time: 9ms
memory: 4112kb

input:

69941

output:

POSSIBLE
1 1
2 4
3 7
4 10
7 9
6 6
5 3
8 2
9 5
10 8
11 11
12 14
15 15
16 12
13 13
14 16
17 17
18 20
21 21
22 18
19 19
20 22
23 23
24 26
27 27
28 24
25 25
26 28
29 29
30 32
33 33
34 30
31 31
32 34
35 35
36 38
39 39
40 36
37 37
38 40
41 41
42 44
45 45
46 42
43 43
44 46
47 47
48 50
51 51
52 48
49 49
50 ...

result:

ok answer = 1

Test #59:

score: 0
Accepted
time: 4ms
memory: 3696kb

input:

24192

output:

POSSIBLE
1 3
4 4
5 1
2 2
3 5
6 6
7 9
10 10
11 7
8 8
9 11
12 12
13 15
16 16
17 13
14 14
15 17
18 18
19 21
22 22
23 19
20 20
21 23
24 24
25 27
28 28
29 25
26 26
27 29
30 30
31 33
34 34
35 31
32 32
33 35
36 36
37 39
40 40
41 37
38 38
39 41
42 42
43 45
46 46
47 43
44 44
45 47
48 48
49 51
52 52
53 49
50 ...

result:

ok answer = 1

Test #60:

score: 0
Accepted
time: 3ms
memory: 3812kb

input:

13677

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9
10 12
13 13
14 10
11 11
12 14
15 15
16 18
19 19
20 16
17 17
18 20
21 21
22 24
25 25
26 22
23 23
24 26
27 27
28 30
31 31
32 28
29 29
30 32
33 33
34 36
37 37
38 34
35 35
36 38
39 39
40 42
43 43
44 40
41 41
42 44
45 45
46 48
49 49
50 46
47 47
48 50
51 51
52 ...

result:

ok answer = 1

Test #61:

score: 0
Accepted
time: 6ms
memory: 3832kb

input:

47780

output:

POSSIBLE
1 3
2 6
5 7
4 4
3 1
6 2
7 5
8 8
9 11
12 12
13 9
10 10
11 13
14 14
15 17
18 18
19 15
16 16
17 19
20 20
21 23
24 24
25 21
22 22
23 25
26 26
27 29
30 30
31 27
28 28
29 31
32 32
33 35
36 36
37 33
34 34
35 37
38 38
39 41
42 42
43 39
40 40
41 43
44 44
45 47
48 48
49 45
46 46
47 49
50 50
51 53
54 ...

result:

ok answer = 1

Test #62:

score: 0
Accepted
time: 5ms
memory: 3764kb

input:

36022

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16
17 19
20 20
21 17
18 18
19 21
22 22
23 25
26 26
27 23
24 24
25 27
28 28
29 31
32 32
33 29
30 30
31 33
34 34
35 37
38 38
39 35
36 36
37 39
40 40
41 43
44 44
45 41
42 42
43 45
46 46
47 49
50 50
51 47
48 48
49 51
52 ...

result:

ok answer = 1

Test #63:

score: 0
Accepted
time: 2ms
memory: 3808kb

input:

50675

output:

POSSIBLE
1 1
2 4
3 7
4 10
7 9
6 6
5 3
8 2
9 5
10 8
11 11
12 14
15 15
16 12
13 13
14 16
17 17
18 20
21 21
22 18
19 19
20 22
23 23
24 26
27 27
28 24
25 25
26 28
29 29
30 32
33 33
34 30
31 31
32 34
35 35
36 38
39 39
40 36
37 37
38 40
41 41
42 44
45 45
46 42
43 43
44 46
47 47
48 50
51 51
52 48
49 49
50 ...

result:

ok answer = 1

Test #64:

score: 0
Accepted
time: 4ms
memory: 3768kb

input:

26644

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16
17 19
20 20
21 17
18 18
19 21
22 22
23 25
26 26
27 23
24 24
25 27
28 28
29 31
32 32
33 29
30 30
31 33
34 34
35 37
38 38
39 35
36 36
37 39
40 40
41 43
44 44
45 41
42 42
43 45
46 46
47 49
50 50
51 47
48 48
49 51
52 ...

result:

ok answer = 1

Test #65:

score: 0
Accepted
time: 4ms
memory: 3816kb

input:

56969

output:

POSSIBLE
1 1
2 4
3 7
4 10
7 9
6 6
5 3
8 2
9 5
10 8
11 11
12 14
15 15
16 12
13 13
14 16
17 17
18 20
21 21
22 18
19 19
20 22
23 23
24 26
27 27
28 24
25 25
26 28
29 29
30 32
33 33
34 30
31 31
32 34
35 35
36 38
39 39
40 36
37 37
38 40
41 41
42 44
45 45
46 42
43 43
44 46
47 47
48 50
51 51
52 48
49 49
50 ...

result:

ok answer = 1

Test #66:

score: 0
Accepted
time: 7ms
memory: 3868kb

input:

53401

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12
13 13
14 16
17 17
18 14
15 15
16 18
19 19
20 22
23 23
24 20
21 21
22 24
25 25
26 28
29 29
30 26
27 27
28 30
31 31
32 34
35 35
36 32
33 33
34 36
37 37
38 40
41 41
42 38
39 39
40 42
43 43
44 46
47 47
48 44
45 45
46 48
49 49
50 52
53 53
54 ...

result:

ok answer = 1

Test #67:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

24772

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16
17 19
20 20
21 17
18 18
19 21
22 22
23 25
26 26
27 23
24 24
25 27
28 28
29 31
32 32
33 29
30 30
31 33
34 34
35 37
38 38
39 35
36 36
37 39
40 40
41 43
44 44
45 41
42 42
43 45
46 46
47 49
50 50
51 47
48 48
49 51
52 ...

result:

ok answer = 1

Test #68:

score: 0
Accepted
time: 2ms
memory: 3796kb

input:

35433

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9
10 12
13 13
14 10
11 11
12 14
15 15
16 18
19 19
20 16
17 17
18 20
21 21
22 24
25 25
26 22
23 23
24 26
27 27
28 30
31 31
32 28
29 29
30 32
33 33
34 36
37 37
38 34
35 35
36 38
39 39
40 42
43 43
44 40
41 41
42 44
45 45
46 48
49 49
50 46
47 47
48 50
51 51
52 ...

result:

ok answer = 1

Test #69:

score: 0
Accepted
time: 1ms
memory: 4244kb

input:

89877

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9
10 12
13 13
14 10
11 11
12 14
15 15
16 18
19 19
20 16
17 17
18 20
21 21
22 24
25 25
26 22
23 23
24 26
27 27
28 30
31 31
32 28
29 29
30 32
33 33
34 36
37 37
38 34
35 35
36 38
39 39
40 42
43 43
44 40
41 41
42 44
45 45
46 48
49 49
50 46
47 47
48 50
51 51
52 ...

result:

ok answer = 1

Test #70:

score: 0
Accepted
time: 8ms
memory: 4204kb

input:

99986

output:

POSSIBLE
1 3
2 6
5 7
4 4
3 1
6 2
7 5
8 8
9 11
12 12
13 9
10 10
11 13
14 14
15 17
18 18
19 15
16 16
17 19
20 20
21 23
24 24
25 21
22 22
23 25
26 26
27 29
30 30
31 27
28 28
29 31
32 32
33 35
36 36
37 33
34 34
35 37
38 38
39 41
42 42
43 39
40 40
41 43
44 44
45 47
48 48
49 45
46 46
47 49
50 50
51 53
54 ...

result:

ok answer = 1

Test #71:

score: 0
Accepted
time: 1ms
memory: 3816kb

input:

6094

output:

POSSIBLE
1 3
2 6
3 9
6 8
5 5
4 2
7 1
8 4
9 7
10 10
11 13
14 14
15 11
12 12
13 15
16 16
17 19
20 20
21 17
18 18
19 21
22 22
23 25
26 26
27 23
24 24
25 27
28 28
29 31
32 32
33 29
30 30
31 33
34 34
35 37
38 38
39 35
36 36
37 39
40 40
41 43
44 44
45 41
42 42
43 45
46 46
47 49
50 50
51 47
48 48
49 51
52 ...

result:

ok answer = 1