1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>

using namespace std;
vector<int>tab[30007];
map<pair<int, int>, int>mapa;
set<pair<int, int>>s;
bool bfs(){

}
int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    int n, w1, w2;
    cin >> n >> w1;
    for(int i = w1; i; --i){
        int a, b;
        cin >> a >> b;
        if(a > b){
            swap(a,b);
        }
        if(find(tab[a].begin(), tab[a].end(), b) != tab[a].end()) tab[a].push_back(b);
        if(find(tab[b].begin(), tab[b].end(), a) != tab[b].end()) tab[b].push_back(a);
        mapa[{a, b}]--;
        s.insert({a, b});
    }
    cin >> w2;
    for(int i = w2; i; --i){
        int a, b;
        cin >> a >> b;
        if(a > b){
            swap(a,b);
        }
        tab[a].push_back(b);
        tab[b].push_back(a);
        mapa[{a, b}]++;
        s.insert({a, b});
    }
    vector<pair<int, int>>p, m;
    for(auto i : s){
        if(mapa[i] > 0){
            p.push_back(i);
        } else if(mapa[i] < 0){
            m.push_back(i);
        }
    }
    for(auto i : p){
        cout << "+ " << i.first << " " << i.second << endl;
    }
    for(auto i : m){
        cout << "- " << i.first << " " << i.second << endl;
    }
}