#include #include #include #include #include #include #include #include #include #include #include #define _fetch(_1, _2, _3, _4, name, ...) name #define rep2(i, n) rep3(i, 0, n) #define rep3(i, a, b) rep4(i, a, b, 1) #define rep4(i, a, b, c) for (int i = int(a); i < int(b); i += int(c)) #define rep(...) _fetch(__VA_ARGS__, rep4, rep3, rep2, _)(__VA_ARGS__) using namespace std; using i64 = long long; using u8 = unsigned char; using u32 = unsigned; using u64 = unsigned long long; using f80 = long double; using u128 = __uint128_t; const u32 N_MAX = 120; u128 edges[N_MAX + 1]; u128 bits[N_MAX + 1]; struct Rand { Rand(u32 seed) : x(seed) {} u32 next() { return x = u64(x) * 12345 % 1000003; } u32 x; }; int gene_graph(int S) { auto gene = Rand(S); int N = gene.next() % N_MAX + 2; int P = gene.next(); rep(i, N) edges[i] = bits[i]; rep(i, N) rep(j, i + 1, N) { int X = gene.next(); if (X >= P) { edges[i] |= u128(1) << j; edges[j] |= u128(1) << i; } } return N; } struct xor64 { xor64(u64 seed) : x(seed) {} u64 next() { x ^= x << 13; x ^= x >> 7; return x ^= x << 17; } u64 x; }; vector rmis(int N) { int perms[N_MAX + 1]; int ret[N_MAX + 1], t[N_MAX + 1]; int max_c = 0; auto gene = xor64(rand()); const auto G = (u128(1) << N) - 1; rep(i, N) perms[i] = i; rep(_, 100000) { u128 V = 0; int c = 0; for (int i = N - 1; i >= 0; --i) { swap(perms[gene.next() % (i + 1)], perms[i]); int v = perms[i]; if (V & bits[v]) continue; V |= edges[v]; t[c++] = v; if (V == G) break; } if (c > max_c) { max_c = c; copy(t, t + c, ret); } } return vector(ret, ret + max_c); } void solve() { srand(time(nullptr)); bits[0] = 1; rep(i, 1, N_MAX + 1) bits[i] = bits[i - 1] << 1; int S; while (~scanf("%d", &S)) { int N = gene_graph(S); auto ans = rmis(N); if (int(ans.size()) == N) { puts("-1"); } else { printf("%u\n", int(ans.size() + 1)); printf("%u", ans[0] + 1); rep(i, 1, ans.size()) printf(" %u", ans[i] + 1); puts(""); } } } int main() { clock_t beg = clock(); solve(); clock_t end = clock(); fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC); return 0; }