#include using namespace std; typedef long long ll; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b>N>>K; vector A(K); for(int i=0;i>A[i]; vector cnt(6); for(int i=K-1;i>=0;i--){ for(int x=0;x<6;x++){ int y=(x+6-(A[i]%6))%6; if(cnt[x]){ if(y==1) cnt[(A[i]+3)%6]=1; if(y==3) cnt[(A[i]+4)%6]=1; if(y==5) cnt[(A[i]+2)%6]=1; } } for(int j=i+1;j