#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) int n, m; int b[8][8]; vector GaussJordanMod2(vector > a) { int n = a.size(); for (int i = 0; i invalid(n); invalid.push_back(1); if (a[i] == invalid)return vector(); for (int j = 0; j res(n); for (int i = 0; i> n >> m; rep(i,n) { rep(j, m) { cin >> b[i][j]; } } int dy[] = { 0,-1,0,1,0 ,1,1,-1,-1}; int dx[] = { 0,0,-1,0,1 ,1,-1,1,-1}; vector> v; rep(i, n) { rep(j, m) { v.emplace_back(n*m + 1); rep(k,9) { int y = i + dy[k]; int x = j + dx[k]; if (0<=x&&x