#include using namespace std; #include using namespace atcoder; using ll=long long; using Graph=vector>>; #define INF 1000000000000000000 #define MOD 998244353 #define MAX 1000000 int main(){ int N,M; cin>>N>>M; vector A(N),P(N),rP(N); for(int i=0;i>A[i]; } for(int i=0;i>P[i]; P[i]--; rP[P[i]]=i; } vector> dp(N+1,vector(M+1,0)); dp[N][M]=1; for(int i=N-1;i>=0;i--){ for(int j=0;j<=M;j++){ dp[i][j]=dp[i+1][j]; } for(int j=0;j+A[i]<=M;j++){ dp[i][j]|=dp[i+1][j+A[i]]; } } if(dp[0][0]==0){ cout<<-1<<'\n'; }else{ vector B; int j=0; int Mi=-1; while(j