Problem: Smart Beaver became interested in drawing. He draws suns. However, at some point, Smart Beaver realized that simply drawing suns is boring. So he decided to design a program that will process his drawings. You are given a picture drawn by the beaver. It will have two colors: one for the background and one for the suns in the image. Your task will be to count the number of suns in the image and for each of them to count the number of rays.

Sun is arbitrarily rotated ellipse with rays. Ray is a segment which connects point on boundary of the ellipse with some point outside ellipse.

<image> An image where all suns are circles.  <image> An image where all suns are ellipses, their axes are parallel to the coordinate axes.  <image> An image where all suns are rotated ellipses. 

It is guaranteed that: 

  * No two suns have common points. 
  * The rays’ width is 3 pixels. 
  * The lengths of the ellipsis suns’ axes will lie between 40 and 200 pixels. 
  * No two rays intersect. 
  * The lengths of all rays will lie between 10 and 30 pixels. 

Input

The first line contains two integers h and w — the height and width of the image (1 ≤ h, w ≤ 1600). Next h lines will contain w space-separated integers each. They describe Smart Beaver’s picture. Each number equals either a 0 (the image background), or a 1 (the sun color).

The input limits for scoring 30 points are (subproblem F1): 

  * All suns on the image are circles. 



The input limits for scoring 70 points are (subproblems F1+F2): 

  * All suns on the image are ellipses with axes parallel to the coordinate axes. 



The input limits for scoring 100 points are (subproblems F1+F2+F3):

  * All suns on the image are ellipses, they can be arbitrarily rotated. 

Output

The first line must contain a single number k — the number of suns on the beaver’s image. The second line must contain exactly k space-separated integers, corresponding to the number of rays on each sun. The numbers of the second line must be sorted in the increasing order.

Examples

Note

For each complexity level you are suggested a sample in the initial data. You can download the samples at http://www.abbyy.ru/sun.zip.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int err;
int bitc(long long r) { return r == 0 ? 0 : (bitc(r >> 1) + (r & 1)); }
long long gcd(long long x, long long y) { return x ? gcd(y % x, x) : y; }
string cts(char c) {
  string s = "";
  s += c;
  return s;
}
char buf[1000000];
string getLine() {
  string s;
  while (!feof(stdin)) {
    char c = fgetc(stdin);
    if (c == 13) continue;
    if (c == 10) return s;
    s += c;
  }
  return s;
}
int getNum() {
  string s = getLine();
  return atoi(s.c_str());
}
vector<int> parsevi(string s) {
  s = s + " ";
  int q = 0;
  bool minus = false;
  vector<int> res;
  for (typeof(0) l = (0); l < ((int(s.size()))); ++l) {
    if (s[l] == ' ') {
      res.push_back(minus ? -q : q);
      q = 0;
      minus = false;
    } else if (s[l] == '-') {
      minus = true;
    } else {
      q = q * 10 + s[l] - '0';
    }
  }
  return res;
}
int Cases, cnum;
int K;
int X, Y;
short bmp[1600][1600];
int uds[1600][1600];
int dfsres;
void dfs1(short x, short y) {
  if (bmp[y][x] != 1) return;
  bmp[y][x] = 0;
  dfs1(x - 1, y);
  dfs1(x + 1, y);
  dfs1(x, y - 1);
  dfs1(x, y + 1);
}
void dfs3(short x, short y) {
  if (bmp[y][x] == 0) return;
  if (bmp[y][x] == 1) {
    dfs1(x, y);
    dfsres++;
    return;
  }
  bmp[y][x] = 0;
  dfs3(x - 1, y);
  dfs3(x + 1, y);
  dfs3(x, y - 1);
  dfs3(x, y + 1);
}
void solveCase() {
  int res = 0;
  err = scanf("%d%d", &Y, &X);
  for (typeof(0) y = (0); y < (Y); ++y)
    for (typeof(0) x = (0); x < (X); ++x) {
      int b;
      err = scanf("%d", &b);
      bmp[y][x] = b;
    }
  for (typeof(0) y = (0); y < (Y); ++y)
    for (typeof(1) x = (1); x < (X); ++x)
      uds[y][x] = uds[y][x - 1] + bmp[y][x - 1];
  for (typeof(1) y = (1); y < (Y); ++y)
    for (typeof(0) x = (0); x < (X); ++x) uds[y][x] = uds[y][x] + uds[y - 1][x];
  for (typeof(0) y = (0); y < (Y); ++y)
    for (typeof(0) x = (0); x < (X); ++x)
      if (y == 0 || x == 0 || y == Y - 1 || x == X - 1) bmp[y][x] = 0;
  for (typeof(4) y = (4); y < (Y - 4); ++y)
    for (typeof(4) x = (4); x < (X - 4); ++x) {
      int tot = uds[y + 4][x + 4] - uds[y - 4][x + 4] - uds[y + 4][x - 4] +
                uds[y - 4][x - 4];
      if (tot == 64) bmp[y][x] = 2;
    }
  for (typeof(0) y = (0); y < (Y); ++y)
    for (typeof(0) x = (0); x < (X); ++x) uds[y][x] = (bmp[y][x] == 2) ? 1 : 0;
  for (typeof(0) y = (0); y < (Y); ++y)
    for (typeof(1) x = (1); x < (X); ++x) uds[y][x] = uds[y][x - 1] + uds[y][x];
  for (typeof(1) y = (1); y < (Y); ++y)
    for (typeof(0) x = (0); x < (X); ++x) uds[y][x] = uds[y][x] + uds[y - 1][x];
  for (typeof(6) y = (6); y < (Y - 6); ++y)
    for (typeof(6) x = (6); x < (X - 6); ++x) {
      int tot = uds[y + 6][x + 6] - uds[y - 6][x + 6] - uds[y + 6][x - 6] +
                uds[y - 6][x - 6];
      if (tot > 0) bmp[y][x] = 3;
    }
  vector<int> v;
  for (typeof(0) y = (0); y < (Y); ++y)
    for (typeof(0) x = (0); x < (X); ++x)
      if (bmp[y][x] == 3) {
        dfsres = 0;
        dfs3(x, y);
        v.push_back(dfsres);
      }
  if (0)
    for (typeof(0) y = (0); y < (Y); ++y) {
      for (typeof(0) x = (0); x < (X); ++x) printf("%d", bmp[y][x]);
      printf("\n");
    }
  sort(v.begin(), v.end());
  printf("%d\n", (int(v.size())));
  for (typeof(0) a = (0); a < ((int(v.size()))); ++a)
    printf("%d%c", v[a], a == (int(v.size())) - 1 ? '\n' : ' ');
}
int main() {
  if (1)
    Cases = 1;
  else if (0) {
    string Nstr = getLine();
    Cases = atoi(Nstr.c_str());
  } else {
    err = scanf("%d", &Cases);
  }
  for (cnum = 1; cnum <= Cases; cnum++) solveCase();
  return 0;
}