sol 中的代码,勿删。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <utility>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <random>
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define debug(x) cout<<#x<<"="<<x<<'\n'
#define all(vc) vc.begin(),vc.end()
#define SZ(x) ((int)(x).size())
#define lwb lower_bound
#define upr upper_bound
#define pb push_back
#define x0 __xx00
#define y0 __yy00
#define x1 __xx11
#define y1 __yy11
#define fi first
#define se second
using namespace std;
const int Base=10;
constexpr int md=998244353;
bool Mbe;
typedef unsigned long long ull;
typedef long double ldb;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef __int128 i128;
mt19937 rd(time(0));
ll rnd(ll l,ll r){return 1ll*abs((int)rd())*abs((int)rd())%(r-l+1)+l;}
template<typename T>
T inv(const T& x,const T& y){
assert(x!=0);
T u=0,v=1,a=x,m=y,t;
while(a!=0){
t=m/a;
swap(a,m-=t*a);
swap(u-=t*v,v);
}
assert(m==1);
return u;
}
template<typename T>
class Modular{
public:
using Type=typename decay<decltype(T::value)>::type;
constexpr Modular():value(){}
template<typename U> Modular(const U& x){value=normalize(x);}
template<typename U> static Type normalize(const U& x){
Type v=static_cast<Type>((-mod()<=x&&x<mod())?x:x%mod());
if(v<0)v+=mod();
return v;
}
const Type& operator()()const{return value;}
template<typename U> explicit operator U()const{return static_cast<U>(value);}
constexpr static Type mod(){return T::value;}
Modular& operator+=(const Modular& other){
if((value+=other.value)>=mod())value-=mod();
return*this;
}
Modular& operator-=(const Modular& other){
if((value-=other.value)<0)value+=mod();
return*this;
}
template<typename U> Modular& operator+=(const U& other){return*this+=Modular(other);}
template<typename U> Modular& operator-=(const U& other){return*this-=Modular(other);}
Modular& operator++(){return*this+=1;}
Modular& operator--(){return*this-=1;}
Modular operator++(int){
Modular result(*this);
*this+=1;
return result;
}
Modular operator--(int){
Modular result(*this);
*this-=1;
return result;
}
Modular operator-()const{return Modular(-value);}
template<typename U= T>
typename enable_if<is_same<typename Modular<U>::Type,int>::value,Modular>::type& operator*=(const Modular& rhs){
#ifdef _WIN32
uint64_t x=static_cast<int64_t>(value)*static_cast<int64_t>(rhs.value);
uint32_t xh=static_cast<uint32_t>(x>>32),xl=static_cast<uint32_t>(x),d,m;
asm(
"divl %4; \n\t"
:"=a"(d),"=d"(m)
:"d"(xh),"a"(xl),"r"(mod()));
value=m;
#else
value=normalize(static_cast<int64_t>(value)*static_cast<int64_t>(rhs.value));
#endif
return*this;
}
template<typename U= T>
typename enable_if<is_same<typename Modular<U>::Type,long long>::value,Modular>::type& operator*=(const Modular& rhs){
long long q=static_cast<long long>(static_cast<long double>(value)*rhs.value/mod());
value=normalize(value*rhs.value-q*mod());
return*this;
}
template<typename U= T>
typename enable_if<!is_integral<typename Modular<U>::Type>::value,Modular>::type& operator*=(const Modular& rhs){
value=normalize(value*rhs.value);
return*this;
}
Modular& operator/=(const Modular& other){return*this*=Modular(inv(other.value,mod()));}
friend const Type& abs(const Modular& x){return x.value;}
template<typename U> friend bool operator==(const Modular<U>& lhs,const Modular<U>& rhs);
template<typename U> friend bool operator<(const Modular<U>& lhs,const Modular<U>& rhs);
template<typename V,typename U> friend V& operator>>(V& stream,Modular<U>& number);
private:
Type value;
};
template<typename T> bool operator==(const Modular<T>& lhs,const Modular<T>& rhs){return lhs.value==rhs.value;}
template<typename T,typename U> bool operator==(const Modular<T>& lhs,U rhs){return lhs==Modular<T>(rhs);}
template<typename T,typename U> bool operator==(U lhs,const Modular<T>& rhs){return Modular<T>(lhs)==rhs;}
template<typename T> bool operator!=(const Modular<T>& lhs,const Modular<T>& rhs){return!(lhs==rhs);}
template<typename T,typename U> bool operator!=(const Modular<T>& lhs,U rhs){return!(lhs==rhs);}
template<typename T,typename U> bool operator!=(U lhs,const Modular<T>& rhs){return!(lhs==rhs);}
template<typename T> bool operator<(const Modular<T>& lhs,const Modular<T>& rhs){return lhs.value<rhs.value;}
template<typename T> Modular<T> operator+(const Modular<T>& lhs,const Modular<T>& rhs){return Modular<T>(lhs)+=rhs;}
template<typename T,typename U> Modular<T> operator+(const Modular<T>& lhs,U rhs){return Modular<T>(lhs)+=rhs;}
template<typename T,typename U> Modular<T> operator+(U lhs,const Modular<T>& rhs){return Modular<T>(lhs)+=rhs;}
template<typename T> Modular<T> operator-(const Modular<T>& lhs,const Modular<T>& rhs){return Modular<T>(lhs)-=rhs;}
template<typename T,typename U> Modular<T> operator-(const Modular<T>& lhs,U rhs){return Modular<T>(lhs)-=rhs;}
template<typename T,typename U> Modular<T> operator-(U lhs,const Modular<T>& rhs){return Modular<T>(lhs)-=rhs;}
template<typename T> Modular<T> operator*(const Modular<T>& lhs,const Modular<T>& rhs){return Modular<T>(lhs)*=rhs;}
template<typename T,typename U> Modular<T> operator*(const Modular<T>& lhs,U rhs){return Modular<T>(lhs)*=rhs;}
template<typename T,typename U> Modular<T> operator*(U lhs,const Modular<T>& rhs){return Modular<T>(lhs)*=rhs;}
template<typename T> Modular<T> operator/(const Modular<T>& lhs,const Modular<T>& rhs){return Modular<T>(lhs)/=rhs;}
template<typename T,typename U> Modular<T> operator/(const Modular<T>& lhs,U rhs){return Modular<T>(lhs)/=rhs;}
template<typename T,typename U> Modular<T> operator/(U lhs,const Modular<T>& rhs){return Modular<T>(lhs)/=rhs;}
template<typename T,typename U> Modular<T> qpow(const Modular<T>& a,const U& b){
assert(b>=0);
Modular<T> x=a,res=1;
for(T p=b;p;x*=x,p>>=1)if(p&1)res*=x;
return res;
}
template<typename T> bool IsZero(const Modular<T>& number){return number()==0;}
template<typename T> string to_string(const Modular<T>& number){return to_string(number());}
template<typename U,typename T> U& operator<<(U& stream,const Modular<T>& number){return stream<<number();}
template<typename U,typename T> U& operator>>(U& stream,Modular<T>& number){
typename common_type<typename Modular<T>::Type,long long>::type x;
stream>>x;
number.value=Modular<T>::normalize(x);
return stream;
}
using Mint=Modular<std::integral_constant<decay<decltype(md)>::type,md>>;
struct Fact{
vector<Mint> fact,factinv;
const int n;
Fact(const int&_n):n(_n),fact(_n+1,Mint(1)),factinv(_n+1){
for(int i=1;i<=n;++i)fact[i]=fact[i-1]*i;
factinv[n]=inv(fact[n](),md);
for(int i=n;i;--i)factinv[i-1]=factinv[i]*i;
}
Mint C(const int&n,const int&k){
if(n<0||k<0||n<k)return 0;
return fact[n]*factinv[k]*factinv[n-k];
}
Mint A(const int&n,const int&k){
if(n<0||k<0||n<k)return 0;
return fact[n]*factinv[n-k];
}
};
namespace NTT{
const int N=2e5+5,G=3;
Mint qpow(Mint a,int b,int p){
Mint res=1;
while(b){
if(b&1)res*=a;
b>>=1,a=a*a;
}
return res;
}
int rev[N];
void ntt(Mint*a,int len,int flg){
rep(i,0,len-1)if(i<rev[i])swap(a[i],a[rev[i]]);
for(int i=1;i<len;i<<=1){
Mint gn=qpow(G,(md-1)/(i<<1),md);
for(int j=0;j<len;j+=(i<<1)){
Mint g=1;
for(int k=0;k<i;++k,g=g*gn){
Mint tp1=a[k+j],tp2=g*a[k+j+i];
a[k+j]=tp1+tp2,a[k+j+i]=tp1-tp2;
}
}
}
if(flg==1)return;
Mint inv=qpow(len,md-2,md);
reverse(a+1,a+len);
rep(i,0,len-1)a[i]=a[i]*inv;
}
void convolution(Mint*a,Mint*b,Mint*c,int n,int m){
int len=1,lim=0;
while(len<=n+m)len<<=1,++lim;
rep(i,0,len-1)rev[i]=(rev[i>>1]>>1)|((i&1)<<(lim-1));
ntt(a,len,1),ntt(b,len,1);
rep(i,0,len-1)a[i]*=b[i];
ntt(a,len,-1);
rep(i,0,n+m)c[i]=a[i];
}
};
template<typename tp> inline void tomax(tp&a,tp v){if(a<v)a=v;}
template<typename tp> inline void tomin(tp&a,tp v){if(v<a)a=v;}
template<typename tp> inline void read(tp&n){
tp x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
n=x*f;
}
template<typename tp> inline void print(tp x){
if(x<0)putchar('-'),x=-x;
if(x>9)print(x/10);
putchar(x%10+'0');
}
template<typename tp> inline tp qmi(tp a,tp b,tp p){
tp res=1;
while(b){
if(b&1)res=1ll*res*a%p;
a=1ll*a*a%p;
b>>=1;
}
return res;
}
template<typename tp> inline tp gcd(tp a,tp b){
return!b?a:gcd(b,a%b);
}
pll exgcd(ll a,ll b){
if(!b)return{1,0};
pll tmp=exgcd(b,a%b);
return{tmp.se,tmp.fi-(a/b)*tmp.se};
}
typedef class BigInteger:public vector<ll>{
public:
using vector<ll>::vector;
void shrink(){while(size()>1u&&!back())pop_back();}
friend BigInteger operator+(BigInteger a,BigInteger b){
int n=max(a.size(),b.size())+1;
a.resize(n,0);
b.resize(n,0);
rep(j,0,n-1)if((a[j]+=b[j])>=Base){a[j]-=Base;a[j+1]+=1;}
a.shrink();
return a;
}
friend BigInteger operator/(BigInteger a,int b){
int n=a.size(),p=0;
per(j,n-1,0){
p=p*Base+a[j];
a[j]=p/b;
p%=b;
}
a.shrink();
return a;
}
friend BigInteger operator*(BigInteger a,BigInteger b){
int n=a.size(),m=b.size();
BigInteger c(n+m,0);
rep(i,0,n-1)for(int j=0,s=i;j<m;j++,s++){
c[s]+=a[i]*b[j];
c[s+1]+=c[s]/Base;
c[s]%=Base;
}
for(int i=1;i<n+m;i++){
c[i]+=c[i-1]/Base;
c[i-1]%=Base;
}
while(c.size()>1u&&!c.back())c.pop_back();
return c;
}
friend istream& operator>>(istream&is,BigInteger&a){
string s;
cin>>s;
int n=s.size();
per(j,n-1,0)a.pb(s[j]-'0');
return is;
}
friend ostream& operator<<(ostream&os,BigInteger&a){
int n=a.size();
per(j,n-1,0)print(a[j]);
return os;
}
}BigInteger;
const int N=15;
int n,m;
ll c,a[N+5];
ll lim[N+5];
int len;
Mint f[N+5][2][2];
int p[N],rnk[N];
int edge[1<<N];
Mint edgexs[1<<N],maskxs[1<<N],tmpmaskxs[1<<N];
/*
edgexs[S]:点集 S 内的边集的(合法)系数之和,题解中提到的 F。
maskxs[S]:题解中提到的 G。
*/
Mint getval(){
Mint ans=0;
per(bit,61,0){
rep(i,0,len)rep(j,0,1)rep(k,0,1) f[i][j][k]=0;
f[0][0][0]=1;
ll upxor=0;
rep(i,1,len){
upxor^=(lim[i]>>(bit+1));
ll low1=(lim[i]&((1ll<<bit)-1))+1,low2=(1ll<<bit);
/*
low1 为 i 这一位顶到上界的情况下比 bit 低的位的方案数
low2 为 i 这一位没有顶到上界的情况下 ...
*/
if(lim[i]>>bit&1){
f[i][0][0]=f[i-1][0][1]*low1;
f[i][0][1]=f[i-1][0][0]*low1;
f[i][1][0]=f[i-1][1][0]*low2+f[i-1][1][1]*low1+f[i-1][0][0];
f[i][1][1]=f[i-1][1][1]*low2+f[i-1][1][0]*low1+f[i-1][0][1];
}else{
rep(j,0,1)rep(k,0,1) f[i][j][k]=f[i-1][j][k]*low1;
}
}
if(!upxor){
ans+=f[len][1][0];
if(!bit) ans+=f[len][0][0];
}
}
return ans;
}
Mint maskval(int mask){
len=0;
Mint res=0;
rep(i,0,n-1) if(mask>>i&1)
lim[++len]=a[i];
lim[++len]=c;
res+=getval();
lim[len]=c-1;
res-=getval();
return res;
}
int count(int s){
int res=0;
while(s)++res,s-=(s&(-s));
return res;
}
bool cmp(const int &x,const int &y){
return a[x]<a[y];
}
void v1ne0qrs(){
}
void solve(){
cin>>n>>m>>c;
rep(i,0,n-1) cin>>a[i];
rep(i,0,n-1) p[i]=i;
sort(p,p+n,cmp);
rep(i,0,n-1) rnk[p[i]]=i;
rep(i,1,m){
int u,v; cin>>u>>v;
u-=1,v-=1;
u=rnk[u],v=rnk[v];
++edge[(1<<u)|(1<<v)]=1;
}
sort(a,a+n);
rep(j,0,n-1)rep(i,0,(1<<n)-1)
if(i>>j&1) edge[i]+=edge[i^(1<<j)];
rep(i,0,(1<<n)-1){
edgexs[i]=!edge[i];
for(int j=(i^(i&(-i)));j;j=(j-1)&(i^(i&(-i))))
if(!edge[j]) edgexs[i]-=edgexs[i^j];
}
maskxs[0]=1;
rep(i,0,n-1){
rep(j,0,(1<<n)-1) tmpmaskxs[j]=0;
rep(j,0,(1<<n)-1){
if(j>>i&1){
tmpmaskxs[j^(1<<i)]+=maskxs[j];
continue;
}
for(int mask=((((1<<n)-1)^j)&((1<<n)-(1<<i+1))); ; mask=(mask-1)&((((1<<n)-1)^j)&((1<<n)-(1<<i+1)))){
if(count(mask)&1) tmpmaskxs[j|mask]+=maskxs[j]*edgexs[mask|(1<<i)]*(a[i]+1);
else tmpmaskxs[(j|mask)^(1<<i)]+=maskxs[j]*edgexs[mask|(1<<i)];
if(!mask) break;
}
}
rep(j,0,(1<<n)-1) maskxs[j]=tmpmaskxs[j];
}
Mint ans=0;
rep(i,0,(1<<n)-1){
if(!maskxs[i]) continue;
ans+=maskval(i)*maskxs[i];
}
cout<<ans<<'\n';
}
bool Med;
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n";
v1ne0qrs();
int cid,T=1;
// cin>>cid;
// cin>>T;
while(T--)solve();
cerr<<"\n"<<clock()*1.0/CLOCKS_PER_SEC*1000<<"ms\n";
return 0;
}