#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int inf = 1e18;
long long int N = 200005;
void init_code() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
long long int power(long long int a, long long int b, long long int m) {
  a %= m;
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int parent1[1005] = {};
long long int size1[1005] = {};
long long int parent2[1005] = {};
long long int size2[1005] = {};
long long int get(long long int a, long long int parent[]) {
  if (parent[a] == a) return a;
  return parent[a] = get(parent[a], parent);
}
void Union(long long int a, long long int b, long long int parent[],
           long long int size[]) {
  long long int p1 = get(a, parent);
  long long int p2 = get(b, parent);
  if (p1 == p2) return;
  if (size[p1] < size[p2]) {
    parent[p1] = p2;
    size[p2] += size[p1];
  } else {
    parent[p2] = p1;
    size[p1] += size[p2];
  }
}
signed main() {
  init_code();
  long long int n, m1, m2;
  cin >> n >> m1 >> m2;
  for (long long int i = 1; i <= n; ++i) {
    parent1[i] = i;
    parent2[i] = i;
    size1[i] = 1;
    size2[i] = 1;
  }
  for (long long int i = 0; i < m1; ++i) {
    long long int u, v;
    cin >> u >> v;
    Union(u, v, parent1, size1);
  }
  for (long long int i = 0; i < m2; ++i) {
    long long int u, v;
    cin >> u >> v;
    Union(u, v, parent2, size2);
  }
  vector<pair<long long int, long long int>> vt;
  for (long long int i = 1; i <= n; ++i) {
    for (long long int j = 1; j <= n; ++j) {
      if (get(i, parent1) != get(j, parent1) &&
          get(i, parent2) != get(j, parent2)) {
        vt.push_back({i, j});
        Union(i, j, parent1, size1);
        Union(i, j, parent2, size2);
      }
    }
  }
  cout << vt.size() << '\n';
  for (auto it : vt) {
    cout << it.first << " " << it.second << '\n';
  }
}
