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
54
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e4+7;
vector<int>V[LIM];
vector<pair<char,pair<int,int>>>P;
pair<int,int>kraw[LIM];
int odw[LIM], czy[LIM], n, m;
void DFS(int x) {
  odw[x]=1;
  for(auto i : V[x]) if(!odw[i]) {
    if(!czy[i]) {
      P.pb({'+', {0, i}});
      czy[i]=1;
    }
    DFS(i);
  }
}
void solve() {
  P.clear();
  rep(i, n) {
    V[i].clear();
    odw[i]=czy[i]=0;
  }
  czy[0]=1;
  cin >> m;
  rep(i, m) {
    cin >> kraw[i].st >> kraw[i].nd;
    --kraw[i].st; --kraw[i].nd;
    V[kraw[i].st].pb(kraw[i].nd);
    V[kraw[i].nd].pb(kraw[i].st);
    if(!kraw[i].st) czy[kraw[i].nd]=1;
    if(!kraw[i].nd) czy[kraw[i].st]=1;
  }
  DFS(0);
  rep(i, m) if(kraw[i].st && kraw[i].nd) P.pb({'-', {kraw[i].st, kraw[i].nd}});
}
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin >> n;
  solve();
  vector<pair<char,pair<int,int>>>ans=P;
  solve();
  reverse(all(P));
  for(auto i : P) if(i.st=='+') ans.pb({'-', i.nd}); else ans.pb({'+', i.nd});
  cout << ans.size() << '\n';
  for(auto i : ans) cout << i.st << " " << i.nd.st+1 << " " << i.nd.nd+1 << '\n';
}