func_code_string: #include <bits/stdc++.h>   const bool DEBUG = false;   using namespace std;   const long long maxn = 2e5 + 5;   const long long INF = 1e18 + 1;   const long long M = 1e9 + 7;   const int lg = 21;   int n, m, x[maxn], b[maxn], a[maxn], y[maxn];   vector<pair<int, int> > v;   set<int> s;   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> x[i] >> y[i];     for (int i = 0; i < m; i++) cin >> a[i] >> b[i];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[j] == b[j] or x[i] == y[i]) continue;         if (a[j] == x[i] and b[j] == y[i]) continue;         if (a[j] == y[i] and b[j] == x[i]) continue;         if (a[j] != x[i] and a[j] != y[i] and b[j] != x[i] and b[j] != y[i])           continue;         if (a[j] == x[i] or a[j] == y[i])           s.insert(a[j]);         else           s.insert(b[j]);       }     }     if (s.size() == 1) return cout << (*s.begin()) << endl, 0;     for (int i = 0; i < n; i++) {       vector<int> v;       set<int> s;       for (int j = 0; j < m; j++) {         if (a[j] == b[j] or x[i] == y[i]) continue;         if (a[j] == x[i] and b[j] == y[i]) continue;         if (a[j] == y[i] and b[j] == x[i]) continue;         if (a[j] != x[i] and a[j] != y[i] and b[j] != x[i] and b[j] != y[i])           continue;         if (x[i] == a[j] or x[i] == b[j])           s.insert(x[i]);         else           s.insert(y[i]);       }       if (s.size() > 1) return cout << -1 << endl, 0;     }     for (int i = 0; i < m; i++) {       vector<int> v;       set<int> s;       for (int j = 0; j < n; j++) {         if (a[i] == b[i] or x[j] == y[j]) continue;         if (a[i] == x[j] and b[i] == y[j]) continue;         if (a[i] == y[j] and b[i] == x[j]) continue;         if (a[i] != x[j] and a[i] != y[j] and b[i] != x[j] and b[i] != y[j])           continue;         if (x[j] == a[i] or a[i] == y[j])           s.insert(a[i]);         else           s.insert(b[i]);       }       if (s.size() > 1) return cout << -1 << endl, 0;     }     cout << 0 << endl;     return 0;   }   