Dogs

아직 제출이 없습니다시간 제한2초메모리 제한256 MB

문제

In a village, there are nn villagers labeled with 1,2,,n1, 2, \ldots, n. Each villager keeps a dog, and the dog is either healthy or sick.

One day (denoted as day 00), a man comes to the village and tells all the villagers an unpleasant truth: there is at least one sick dog in the village.

On day tt (t1t \geq 1), the each villager ii inspects the dog of every villager jj such that G_i,j=1G\_{i, j} = 1. All values G_i,jG\_{i, j} are given in advance and known to all the villagers. For each dog inspected, the villager learns whether it is healthy or sick.

After all the inspections, if a villager can conclude that his own dog is sick, he shoots it in the afternoon. If more than one villager can reach such conclusion, they all shoot simultaneously. All villagers immediately hear the shots. After that, nobody does anything about dogs until the next day.

The villagers don't exchange information in any way except what is mentioned above.

  • If any shooting occurs on day tt, the above process ends with shoot time tt.
  • If t<233nt < 233^n, the process continues on day (t+1)(t+1).
  • Otherwise, the process ends with shoot time 00.

For each of the (2n1)(2^n-1) possibilities of the health status of dogs, we record two values: the shoot time and how many dogs were shot. Find two sums: the sum of all recorded shoot times and the sum of the amounts of dogs shot. As both may be very large, find them modulo 998,244,353998\\,244\\,353.

입력

The first line contains an integer nn (1n30001 \leq n \leq 3000).

The ii-th of the following nn lines contains nn binary digits without spaces: G_i,1,G_i,2,,G_i,nG\_{i, 1}, G\_{i, 2}, \ldots, G\_{i, n} (G_i,j0,1G\_{i, j} \in \\{0, 1\\}, G_i,i=0G\_{i, i} = 0).

출력

On the first line, print two integers: the sum of all recorded shoot times and the sum of the amounts of dogs shot, both modulo 998,244,353998\\,244\\,353.

힌트

For the first sample, there are three possible configurations:

  1. Dog 11 is sick while dog 22 is not. Villager 11 finds no dogs other than his are sick, so he shoots his own dog on day 11.
  2. Dog 22 is sick while dog 11 is not. On day 11, villager 11 is not sure about his dog, so he does nothing. On day 22, villager 22 knows his dog must be sick, or villager 11 would shoot his own dog on day 11.
  3. Both dogs are sick. This case is similar to the second case.