#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector W(20),B(20); while(N--){ int w; cin >> w; w--; W.at(w) = true; } cin >> N; while(N--){ int b; cin >> b; b--; B.at(b) = true; } vector dpW(20,-1000),dpB(20,-1000); for(int i=0; i<20; i++){ if(W.at(i)) dpW.at(i) = 1; if(B.at(i)) dpB.at(i) = 1; } int answer = 0; for(int i=19; i>=0; i--){ if(W.at(i)){ int now = -1000; for(int k=i+1; k<20; k++) now = max(now,dpB.at(k)); if(now != -1000) dpW.at(i) = now+1; } if(B.at(i)){ int now = -1000; for(int k=i+1; k<20; k++) now = max(now,dpW.at(k)); if(now != -1000) dpB.at(i) = now+1; } answer = max(answer,dpW.at(i)); answer = max(answer,dpB.at(i)); } cout << answer << endl; }