#include <bits/stdc++.h>
using namespace std;
int fa1[1010];
int fa2[1010];
struct node {
  int x, y;
} a[1010];
int findl1(int x) {
  if (x == fa1[x])
    return fa1[x];
  else {
    fa1[x] = findl1(fa1[x]);
    return fa1[x];
  }
}
void f1(int x, int y) {
  int a = findl1(x);
  int b = findl1(y);
  if (a == b)
    return;
  else
    fa1[b] = a;
}
int findl2(int x) {
  if (x == fa2[x])
    return fa2[x];
  else {
    fa2[x] = findl2(fa2[x]);
    return fa2[x];
  }
}
void f2(int x, int y) {
  int a = findl2(x);
  int b = findl2(y);
  if (a == b)
    return;
  else
    fa2[b] = a;
}
int main() {
  int i, j;
  for (i = 1; i <= 1000; i++) {
    fa1[i] = i;
    fa2[i] = i;
  }
  int n, m1, m2;
  cin >> n >> m1 >> m2;
  for (i = 0; i < m1; i++) {
    int x, y;
    cin >> x >> y;
    f1(x, y);
  }
  for (i = 0; i < m2; i++) {
    int x, y;
    cin >> x >> y;
    f2(x, y);
  }
  int cnt = 0;
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      if (findl1(i) != findl1(j) && findl2(i) != findl2(j)) {
        a[cnt].x = i;
        a[cnt].y = j;
        cnt++;
        f1(i, j);
        f2(i, j);
      }
    }
  }
  cout << cnt << endl;
  for (i = 0; i < cnt; i++) {
    cout << a[i].x << ' ' << a[i].y << endl;
  }
  return 0;
}
