#include using namespace std; int main(){ int N, M; cin >> N >> M; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector P(N); for (int i = 0; i < N; i++){ cin >> P[i]; P[i]--; } vector> dp(N + 1, vector(M + 1, false)); dp[N][0] = true; for (int i = N - 1; i >= 0; i--){ for (int j = 0; j <= M; j++){ if (dp[i + 1][j]){ dp[i][j] = true; if (j + A[i] <= M){ dp[i][j + A[i]] = true; } } } } if (!dp[0][M]){ cout << -1 << endl; } else { vector Q(N); for (int i = 0; i < N; i++){ Q[P[i]] = i; } vector ans; int sum = 0; int L = 0; while (sum < M){ for (int i = 0; i < N; i++){ if (Q[i] > L && sum + A[Q[i]] <= M){ if (dp[Q[i] + 1][M - A[Q[i]] - sum]){ ans.push_back(Q[i]); L = Q[i]; sum += A[Q[i]]; break; } } } } int K = ans.size(); cout << K << endl; for (int i = 0; i < K; i++){ cout << ans[i] + 1; if (i < K - 1){ cout << ' '; } } cout << endl; } }