#include using namespace std; #ifdef _RUTHEN #include "debug.hpp" #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template using V = vector; #include using namespace atcoder; using mint = modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(0); ll N, M; cin >> N >> M; V A(N), P(N); rep(i, N) cin >> A[i]; rep(i, N) { cin >> P[i]; P[i]--; } V> dp(N + 1, V(M + 1, 0)); dp[N][0] = 1; for (int i = N - 1; i >= 0; i--) { for (int j = 0; j <= M; j++) { if (dp[i + 1][j] == 0) continue; dp[i][j] = 1; if (j + A[i] <= M) dp[i][j + A[i]] = 1; } } if (dp[0][M] == 0) { cout << -1 << '\n'; return 0; } V ans; int lb = 0; while (M != 0) { int arg = -1; for (int i = lb; i < N; i++) { // A_iを使ってMを作れるか if (M - A[i] < 0) continue; if (dp[i + 1][M - A[i]] == 1) { if (arg == -1) { arg = i; } else if (P[arg] > P[i]) { arg = i; } } } assert(arg != -1); ans.push_back(arg); lb = arg + 1; M -= A[arg]; } cout << ans.size() << '\n'; rep(i, ans.size()) cout << ans[i] + 1 << (i == ans.size() - 1 ? '\n' : ' '); show(ans); return 0; }