#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; ll N, M; int A[50][50]; ll dp[40][50][50], _dp[50][50], __dp[50][50]; // merge dp1 and dp2 -> dp3 void merge(const ll (&dp1)[50][50], const ll (&dp2)[50][50], ll (&dp3)[50][50]){ memset(dp3, 0, sizeof(dp3)); for(int i=0;i> N >> M; for(int i=0;i> A[i][j]; } } for(int i=0;i> i & 1){ if((N & ((1ll << i) - 1)) == 0){ for(int j=0;j