#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define MOD 1000000007ll #define INF 1000000000ll #define EPS 1e-7 #define REP(i,m) for(long long i=0; i<(ll)m; i++) #define FOR(i,n,m) for(long long i=n; i<(ll)m; i++) #define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout< P; typedef long double ld; ll h,w; vector> a; void dfs(P pos) { a[pos.first][pos.second]=0; ll dx[]={1,0,-1,0}; ll dy[]={0,1,0,-1}; REP(i,4) { ll nx=pos.first+dx[i]; ll ny=pos.second+dy[i]; if(nx>=0&&nx=0&&ny>h>>w; a.resize(h,vector(w)); REP(i,h) REP(j,w) cin>>a[i][j]; ll sum=0; REP(i,h) REP(j,w) { if(a[i][j]) { sum++; dfs(P(i,j)); } } cout<