Forest
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

Dense forest in the Western suburbs helps you break loose.
西郊有密林,助君出重围。
Given a weighted undirected simple graph with n vertices and m positive-weighted edges. Sum up the weight of the minimum spanning forest for each of its spanning subgraph, and print the value modulo 998244353 as answer.

minimum spanning forest of a weighted undirected graph G with vertex set V and edge set E is defined as follows:
  • It's a subset of E (not necessarily non-empty or different from E), denoted as S.
  • Any pair of vertices (u, v) which can reach each other in G can still reach each other only using edges in S.
  • S is the subset with minumum weight among all subsets satisfying the above two conditions. The weight of S is the sum of weight of all edges in it.

spanning subgraph of G is a graph with vertex set V and edge set a subset of E (not necessarily non-empty or different from E).

输入描述:

The first line consists of a single integer , denoting the number of vertices in the graph.

The next n lines describes the graph with an adjacency matrix, more specifically:

Each of the n lines consists of n non-negative numbers.
The j-th number of the i-th line is 0, if there's no edge between vertex i and j; or the weight of the only edge between them otherwise.

It's guaranteed that and for each , which ensures the graph is an undirected simple graph with all edges positive-weighted. It's also guaranteed that the number of edges m does not exceed 100.

输出描述:

Print a single integer in the first line, which is the value modulo 998244353.
示例1

输入

复制
4
0 1 1 1
1 0 1 1
1 1 0 1
1 1 1 0

输出

复制
158