#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 1000000007; // constexpr int MOD = 998244353; constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; int main() { int n, m; cin >> n >> m; vector popcount(n + 1, 0); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) { popcount[i] += __builtin_popcount(i * j) % 2 == 0; } const int a = accumulate(ALL(popcount), 0); vector dp(n + 2, vector(a * 2 + 1, false)); dp[1][a] = true; for (int i = 1; i <= n; ++i) { for (int j = popcount[i]; j <= a * 2; ++j) { if (dp[i][j]) dp[i + 1][j - popcount[i]] = true; } for (int j = 0; j + popcount[i] <= a * 2; ++j) { if (dp[i][j]) dp[i + 1][j + popcount[i]] = true; } } if (a < m || !dp[n + 1][a + m]) { cout << "-1\n"; return 0; } vector x, y; for (int i = n; i >= 1; --i) { if (a + m >= popcount[i] && dp[i][a + m - popcount[i]]) { m -= popcount[i]; x.emplace_back(i); } else { assert(m + popcount[i] <= a && dp[i][a + m + popcount[i]]); m += popcount[i]; y.emplace_back(i); } } reverse(ALL(x)); reverse(ALL(y)); int p = x.size(), q = y.size(); cout << p << ' ' << q << '\n'; REP(i, p) cout << x[i] << " \n"[i + 1 == p]; REP(i, q) cout << y[i] << " \n"[i + 1 == q]; return 0; }