ZYB likes to read detective novels and detective cartoons. One day he is immersed in such story:
As a spy of country B, you have been lurking in country A for many years. There are $n$ troops and $m$ legions in country A, and each troop belongs to only one legion. Your task is to investigate which legion each troop belongs to.
One day, you intercept a top secret message--a paper which records all the pairwise relationship between troops. You can learn from the paper that whether troop

and troop

belongs to the same legion for each
%7D)
. However, each piece of data has a independent probability of

being reversed.
Formally, the troop is numbered from

to

, and the region is numbered from

to

. You are given
%7D%7B2%7D)
boolean numbers, indicating whether
and
belong to the same region (1 for yes and 0 for no). However, every number will be reversed(i.e., 0 to 1 and 1 to 0) in a probablity of

. You can assume that the data is generated like this:
be[i] means the region that troop

belongs to.
rand() can be considered as a uniform random function. i.e., select a integer from interval
-1%5D)
with equal probability.
Note that you have already known

and

, but you don't know the exact value of $m$. Please help country B construct the original data.