rt
//#pragma GCC optimize (2)
#include <bits/stdc++.h>
#define int long long
#define PII pair <int, int>
using namespace std;
const int N = 1e5 + 5;
int read () {
int x = 0, y = 1;
char c = getchar ();
while (c < '0' || c > '9') {
if (c == '-') y = -1;
c = getchar ();
}
while (c >= '0' && c <= '9') {
x = (x << 3) + (x << 1) + c - '0';
c = getchar ();
}
return x * y;
}
void write (int x) {
if (x < 0) putchar ('-'), x = -x;
if (x > 9) write (x / 10);
putchar (x % 10 + '0');
}
int n, m1, m2, ans;
int t1[N], t2[N], tmp1[N], tmp2[N];
struct node {
int x, y;
};
node a[N], b[N];
bool cmp (node fir, node sec) {
if (fir.x < sec.x) return true;
else if (fir.x == sec.x && fir.y < sec.y) return true;
return false;
}
void fir_fun () {
priority_queue <int, vector <int>, greater <int> > cnt;
priority_queue <PII, vector <PII>, greater <PII> > q;
int s = 1, res = 1, i = 2;
q.push ({a[s].y, s});
t1[s] = res;
while (!q.empty ()) {
int u = q.top ().second;
q.pop ();
while (i <= m1 && a[i].x < a[u].y) {
if (cnt.empty ()) {
t1[i] = ++ res;
} else {
int v = cnt.top ();
cnt.pop ();
t1[i] = v;
}
q.push ({a[i].y, i});
i ++ ;
}
cnt.push (t1[u]);
}
for (int j = i; j <= m1; j ++ ) t1[j] = ++ res;
}
void sec_fun () {
priority_queue <int, vector <int>, greater <int> > cnt;
priority_queue <PII, vector <PII>, greater <PII> > q;
int s = 1, res = 1, i = 2;
q.push ({b[s].y, s});
t2[s] = res;
while (!q.empty ()) {
int u = q.top ().second;
q.pop ();
while (i <= m2 && b[i].x < b[u].y) {
if (cnt.empty ()) {
t2[i] = ++ res;
} else {
int v = cnt.top ();
cnt.pop ();
t2[i] = v;
}
q.push ({b[i].y, i});
i ++ ;
}
cnt.push (t2[u]);
}
for (int j = i; j <= m2; j ++ ) t2[j] = ++ res;
}
void fd_ans () {
sort (t1 + 1, t1 + m1 + 1);
sort (t2 + 1, t2 + m2 + 1);
int k = 1;
for (int i = 1; i <= n; i ++ ) {
tmp1[i] = tmp1[i - 1];
while (t1[k] <= i && k <= m1) tmp1[i] ++ , k ++ ;
}
k = 1;
for (int i = 1; i <= n; i ++ ) {
tmp2[i] = tmp2[i - 1];
while (t2[k] <= i && k <= m2) tmp2[i] ++ , k ++ ;
}
for (int i = 0; i <= n; i ++ ) ans = max (ans, tmp1[i] + tmp2[n - i]);
}
signed main () {
n = read (), m1 = read (), m2 = read ();
for (int i = 1; i <= m1; i ++ ) a[i].x = read (), a[i].y = read ();
for (int i = 1; i <= m2; i ++ ) b[i].x = read (), b[i].y = read ();
sort (a + 1, a + m1 + 1, cmp);
sort (b + 1, b + m2 + 1, cmp);
fir_fun ();
sec_fun ();
fd_ans ();
for (int i = 0; i <= n; i ++ ) cout << tmp1[i] << " ";
puts ("");
for (int i = 0; i <= n; i ++ ) cout << tmp2[i] << " ";
puts ("");
write (ans);
putchar ('\n');
return 0;
}