Language: C++

#include<bits/stdc++.h>
template<class T> inline void read(T &x){
	x=0; register char c=getchar(); register bool f=0;
	while(!isdigit(c))f^=c=='-',c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar(); if(f)x=-x;
}
template<class T> inline void print(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)print(x/10); putchar(x%10+'0');
}
template<class T> inline void print(T x,char c){print(x),putchar(c);}

const int N=1e5+10,M=400,mod=998244353;
int n,lim,max,m[3],sg[N];
std::vector<int> G[3][N];

struct z {
	int x;
	z(int x=0):x(x){}
	friend inline z operator*(z a,z b){return (long long)a.x*b.x%mod;}
	friend inline z operator-(z a,z b){return (a.x-=b.x)<0?a.x+mod:a.x;}
	friend inline z operator+(z a,z b){return (a.x+=b.x)>=mod?a.x-mod:a.x;}
}ans,pw[N],f[3][N],g[N];
inline z fpow(z a,int b){z s=1;for(;b;b>>=1,a=a*a)if(b&1)s=s*a;return s;}

void SG(int m,std::vector<int> G[N],int sg[N]){
	static bool vis[N];
	for(int i=n;i>=1;i--){
		for(int j:G[i])vis[sg[j]]=1;
		sg[i]=0;
		while(vis[sg[i]])sg[i]++;
		for(int j:G[i])vis[sg[j]]=0;
	}
}

void fwt(z *a){
	for(int len=1;len<lim;len<<=1)
		for(int i=0;i<lim;i+=(len<<1))
			for(int j=0;j<len;j++){
				z x=a[i+j],y=a[i+j+len];
				a[i+j]=x+y,a[i+j+len]=x-y;
			}
}

int main(){
#ifdef memset0
	freopen("1.in","r",stdin);
#endif
	read(n),lim=sqrt(n);
	for(int i=0;i<3;i++){
		read(m[i]);
		for(int u,v,j=1;j<=m[i];j++){
			read(u),read(v);
			// G[i][u].push_back(v);
			G[i][std::min(u,v)].push_back(std::max(u,v));
			// G[i][std::max(u,v)].push_back(std::min(u,v));
		}
	}
	pw[0]=1,pw[1]=fpow(10,18);
	for(int i=2;i<=n;i++)pw[i]=pw[i-1]*pw[1];
	for(int i=0;i<3;i++){
		SG(m[i],G[i],sg);
		for(int j=1;j<=n;j++){
			max=std::max(max,sg[j]);
			f[i][sg[j]]=f[i][sg[j]]+pw[j];
		}
		// for(int j=1;j<=n;j++){
		// 	printf("%d%c",sg[j]," \n"[j==n]);
		// }
	}
	lim=1; while(lim<=max)lim<<=1;
	for(int i=0;i<lim;i++)
		for(int j=0;j<lim;j++)
			for(int k=0;k<lim;k++){
				g[i^j^k]=g[i^j^k]+f[0][i]*f[1][j]*f[2][k];
				// if(f[0][i].x&&f[1][j].x&&f[2][k].x){
				// 	printf("%d %d %d : %d\n",i,j,k,f[0][i]*f[1][j]*f[2][k]);
				// }
			}
	// for(int i=0;i<3;i++)fwt(f[i]);
	// for(int i=0;i<3;i++)g[i]=f[0][i]*f[1][i]*f[2][i];
	// fwt(g);
	// z invlim=fpow(lim,mod-2);
	// for(int i=0;i<lim;i++)g[i]=g[i]*invlim;
	// for(int i=0;i<lim;i++){
	// 	printf("%d : %d\n",i,g[i]);
	// }
	printf("%d\n",g[0]);
}
	for(int i=0;i<3;i++){
		read(m[i]);
		for(int u,v,j=1;j<=m[i];j++){
			read(u),read(v);
			// G[i][u].push_back(v);
			G[i][std::min(u,v)].push_back(std::max(u,v));
			// G[i][std::max(u,v)].push_back(std::min(u,v));
		}
	}
	pw[0]=1,pw[1]=fpow(10,18);
	for(int i=2;i<=n;i++)pw[i]=pw[i-1]*pw[1];
	for(int i=0;i<3;i++){
		SG(m[i],G[i],sg);
		for(int j=1;j<=n;j++){
			max=std::max(max,sg[j]);
			f[i][sg[j]]=f[i][sg[j]]+pw[j];
		}
		// for(int j=1;j<=n;j++){
		// 	printf("%d%c",sg[j]," \n"[j==n]);
		// }
	}
	lim=1; while(lim<=max)lim<<=1;
	for(int i=0;i<lim;i++)
		for(int j=0;j<lim;j++)
			for(int k=0;k<lim;k++){
				g[i^j^k]=g[i^j^k]+f[0][i]*f[1][j]*f[2][k];
				// if(f[0][i].x&&f[1][j].x&&f[2][k].x){
				// 	printf("%d %d %d : %d\n",i,j,k,f[0][i]*f[1][j]*f[2][k]);
				// }
			}
	// for(int i=0;i<3;i++)fwt(f[i]);
	// for(int i=0;i<3;i++)g[i]=f[0][i]*f[1][i]*f[2][i];
	// fwt(g);
	// z invlim=fpow(lim,mod-2);
	// for(int i=0;i<lim;i++)g[i]=g[i]*invlim;
	// for(int i=0;i<lim;i++){
	// 	printf("%d : %d\n",i,g[i]);
	// }
	printf("%d\n",g[0]);
}

Compiler output:
a.cc: In function 'void read(T&)':
a.cc:3:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    3 |         x=0; register char c=getchar(); register bool f=0;
      |                            ^
a.cc:3:55: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    3 |         x=0; register char c=getchar(); register bool f=0;
      |                                                       ^
a.cc: At global scope:
a.cc:90:9: error: expected unqualified-id before 'for'
   90 |         for(int i=0;i<3;i++){
      |         ^~~
a.cc:90:21: error: 'i' does not name a type
   90 |         for(int i=0;i<3;i++){
      |                     ^
a.cc:90:25: error: 'i' does not name a type
   90 |         for(int i=0;i<3;i++){
      |                         ^
a.cc:99:9: error: 'pw' does not name a type
   99 |         pw[0]=1,pw[1]=fpow(10,18);
      |         ^~
a.cc:100:9: error: expected unqualified-id before 'for'
  100 |         for(int i=2;i<=n;i++)pw[i]=pw[i-1]*pw[1];
      |         ^~~
a.cc:100:21: error: 'i' does not name a type
  100 |         for(int i=2;i<=n;i++)pw[i]=pw[i-1]*pw[1];
      |                     ^
a.cc:100:26: error: 'i' does not name a type
  100 |         for(int i=2;i<=n;i++)pw[i]=pw[i-1]*pw[1];
      |                          ^
a.cc:101:9: error: expected unqualified-id before 'for'
  101 |         for(int i=0;i<3;i++){
      |         ^~~
a.cc:101:21: error: 'i' does not name a type
  101 |         for(int i=0;i<3;i++){
      |                     ^
a.cc:101:25: error: 'i' does not name a type
  101 |         for(int i=0;i<3;i++){
      |                         ^
a.cc:111:9: error: 'lim' does not name a type
  111 |         lim=1; while(lim<=max)lim<<=1;
      |         ^~~
a.cc:111:16: error: expected unqualified-id before 'while'
  111 |         lim=1; while(lim<=max)lim<<=1;
      |                ^~~~~
a.cc:112:9: error: expected unqualified-id before 'for'
  112 |         for(int i=0;i<lim;i++)
      |         ^~~
a.cc:112:21: error: 'i' does not name a type
  112 |         for(int i=0;i<lim;i++)
      |                     ^
a.cc:112:27: error: 'i' does not name a type
  112 |         for(int i=0;i<lim;i++)
      |                           ^
a.cc:113:29: error: 'j' does not name a type
  113 |                 for(int j=0;j<lim;j++)
      |                             ^
a.cc:113:35: error: 'j' does not name a type
  113 |                 for(int j=0;j<lim;j++)
      |                                   ^
a.cc:114:37: error: 'k' does not name a type
  114 |                         for(int k=0;k<lim;k++){
      |                                     ^
a.cc:114:43: error: 'k' does not name a type
  114 |                         for(int k=0;k<lim;k++){
      |                                           ^
a.cc:128:15: error: expected constructor, destructor, or type conversion before '(' token
  128 |         printf("%d\n",g[0]);
      |               ^
a.cc:129:1: error: expected declaration before '}' token
  129 | }
      | ^
a.cc: In instantiation of 'void read(T&) [with T = int]':
a.cc:49:6:   required from here
   49 |         read(n),lim=sqrt(n);
      |         ~~~~^~~
a.cc:3:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    3 |         x=0; register char c=getchar(); register bool f=0;
      |                            ^
a.cc:3:55: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    3 |         x=0; register char c=getchar(); register bool f=0;
      |                                                       ^