Stable Group

Time limit1sMemory limit128 MB

Problem

A group of people is stable if it satisfies one of the following conditions.

  • Every two people in the entire group like each other.
  • The group can be divided into several subgroups, every two people in the same subgroup like each other, and every two people in different subgroups dislike each other.

Each subgroup must contain at least 2 people. Therefore, if a person has no other person who likes them mutually, the group is not stable.

The people are numbered from 1 to n. For each pair, the relation is given as 0 if they like each other and 1 if they dislike each other. Given all pairwise relations in the group, determine whether the group is stable. If it is stable, output the subgroup composition.

Input

The first line contains the number of people n (2 ≤ n ≤ 100).

Each of the next n lines contains n integers. The j-th value on the i-th line represents the relation between person i and person j: 0 if they like each other, and 1 if they dislike each other. Adjacent values are separated by one space. Each person is considered to like themselves.

Output

If the group is not stable, print 0 on the first line.

If the group is stable, print the number of mutually liking subgroups on the first line. Then, for each subgroup, print one line containing the numbers of the people in that subgroup, separated by single spaces.

Within each subgroup, print the numbers in increasing order. Print the subgroups in increasing order of the smallest number in each subgroup.