Language: C++

#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
typedef long double f80;
 
// #define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ef emplace_front
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

ll pwr(ll a, ll b) {
    ll ans = 1;
    while(b) {
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

const int N = 2e5 + 5;
bitset<N> b[N][2];
int comp[N][2];
bool vis[N];
vector<pii> g[N];

void dfs(int u,int k,int c) {
    vis[u] = 1;
    comp[u][k] = c;
    b[c][k][u] = 1;
    for(pii v : g[u]) {
        if(!vis[v.fi] && v.se == k) {
            dfs(v.fi, k, c);
        }
    }
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int n, k, l;
    cin >> n >> k >> l;
    fr(i, 1, k) {
        int u, v;
        cin >> u >> v;
        g[u].pb({v, 0});
        g[v].pb({u, 0});
    }
    fr(i ,1, l) {
        int u, v;
        cin >> u >> v;
        g[u].pb({v, 1});
        g[v].pb({u, 1});
    }
    fill(vis + 1, vis + n + 1, 0);
    int c = 0;
    fr(i, 1, n) {
        if(!vis[i]) {
            c++;
            dfs(i, 0, c);
        }
    }
    fill(vis + 1, vis + n + 1, 0);
    c = 0;
    fr(i, 1, n) {
        if(!vis[i]) {
            c++;
            dfs(i, 1, c);
        }
    }
    fr(i, 1, n) {
        cout << (b[comp[i][0]][0] & b[comp[i][1]][1]).count() << " ";
    }
    return 0;
}

Compiler output:
/tmp/ccPXEFAS.o: in function `dfs(int, int, int)':
a.cc:(.text+0xe0): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccPXEFAS.o
a.cc:(.text+0x104): relocation truncated to fit: R_X86_64_PC32 against symbol `comp' defined in .bss section in /tmp/ccPXEFAS.o
a.cc:(.text+0x17c): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccPXEFAS.o
a.cc:(.text+0x1c4): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccPXEFAS.o
/tmp/ccPXEFAS.o: in function `main':
a.cc:(.text+0x2e8): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccPXEFAS.o
a.cc:(.text+0x345): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccPXEFAS.o
a.cc:(.text+0x3ef): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccPXEFAS.o
a.cc:(.text+0x44c): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccPXEFAS.o
a.cc:(.text+0x4bc): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccPXEFAS.o
a.cc:(.text+0x4c7): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccPXEFAS.o
a.cc:(.text+0x4f5): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status