#include using namespace std; #include using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ int n,m;cin>>n>>m; vcv(n); rep(i,n)cin>>v[i]; vcp(n); rep(i,n)cin>>p[i]; rep(i,n)p[i]--; vcr(n); rep(i,n)r[p[i]]=i; vc dp(n+1,vc(m+1,0)); dp[n][0]=1; for(int i=n-1;i>=0;i--)rep(j,m+1)if(dp[i+1][j]){ dp[i][j]=1; if(j+v[i]<=m)dp[i][j+v[i]]=1; } vcans; int last=-1; int now=m; if(!dp[0][m]){ cout<<-1; return 0; } while(now>0){ rep(i,n){ int x=r[i]; if(x<=last)continue; if(v[x]>now||!dp[x+1][now-v[x]])continue; ans.pb(x); last=x; now-=v[x]; } } cout<