Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct edge { ll to; ll d; };
vector<vector<edge>> adj[3];
vector<ll> d[3];
vector<bool> used[3];

void dijkstra(int i, int n) {
  int N = adj[i].size();
  auto c = [](const p_ll &x, const p_ll &y){return x.second>y.second;};
  priority_queue<p_ll, vector<p_ll>, decltype(c)> q(c);
  q.push(make_pair(n,0));
  while(q.size()) {
    p_ll now = q.top(); q.pop();
    ll np = now.first, nd = now.second;
    if (nd>d[i][np]) continue;
    for (auto x: adj[i][np]) {
      if (d[i][x.to]<=d[i][np]+x.d||used[i][x.to]) continue;
      q.push(make_pair(x.to, d[i][np]+x.d));
      d[i][x.to] = d[i][np]+x.d;
    }
  }
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  int N; cin >> N;
  ll p1 = 716070898;
  // ll p1 = 10;
  ll p18[N*3+1] = {}; rep(i,N*3+1) p18[i] = i==0 ? 1 : (p18[i-1]*p1)%MOD;
  ll r[3][3] = {};

  vector<ll> u1[3], u2[3], u3[3];
  rep(i,3) {
    adj[i].resize(N); 
    int M; cin >> M;
    rep(j,M) {
      int a, b; cin >> a >> b; a--; b--;
      adj[i][a].push_back({b,1});
      adj[i][b].push_back({a,1});
    }

    d[i].resize(N,LLINF);
    used[i].resize(N,false);
    per(j,N) {
      if (d[i][j]!=LLINF) continue;
      d[i][j] = 0;
      dijkstra(i,j);
    }
    rep(j,N) {
      if (d[i][j]%2==0) {
        u1[i].push_back(j);
        used[i][j] = true;
      }
    }

    rep(j,N) d[i][j] = LLINF;
    per(j,N) {
      if (d[i][j]!=LLINF||used[i][j]) continue;
      d[i][j] = 0;
      dijkstra(i,j);
    }
    rep(j,N) {
      if (!used[i][j]&&d[i][j]%2==0) {
        u2[i].push_back(j);
        used[i][j] = true;
      }
    }

    rep(j,N) d[i][j] = LLINF;
    per(j,N) {
      if (d[i][j]!=LLINF||used[i][j]) continue;
      d[i][j] = 0;
      dijkstra(i,j);
    }
    rep(j,N) {
      if (!used[i][j]&&d[i][j]%2==0) {
        u23i].push_back(j);
        used[i][j] = true;
      }
    }

    for (auto x: u1[i]) r[i][0] = (r[i][0]+p18[x+1])%MOD;
    for (auto x: u2[i]) r[i][1] = (r[i][1]+p18[x+1])%MOD;
    for (auto x: u3[i]) r[i][2] = (r[i][2]+p18[x+1])%MOD;

  }
  // rep(i,3) { debug(all(u1[i])); debug(all(u2[i])); cout << endl; }

  ll result = 0;
  result = (result+(r[0][0]*r[1][0])%MOD*r[2][0])%MOD;
  result = (result+(r[0][1]*r[1][1])%MOD*r[2][0])%MOD;
  result = (result+(r[0][1]*r[1][0])%MOD*r[2][1])%MOD;
  result = (result+(r[0][0]*r[1][1])%MOD*r[2][1])%MOD;
  result = (result+(r[0][2]*r[1][2])%MOD*r[2][0])%MOD;
  result = (result+(r[0][2]*r[1][0])%MOD*r[2][2])%MOD;
  result = (result+(r[0][0]*r[1][2])%MOD*r[2][2])%MOD;
  cout << result << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:106:9: error: 'u23i' was not declared in this scope; did you mean 'u3'?
  106 |         u23i].push_back(j);
      |         ^~~~
      |         u3