#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
bool ispoweroftwo(long long n) { return n & (!(n & (n - 1))); }
long long mod = 1000000007;
long long dx[] = {1, 0, -1, 0};
long long dy[] = {0, -1, 0, 1};
bool test = 0;
const long long inf = 1e18;
const long long N = 2e5 + 5;
long long n;
long long find(long long u, vector<long long>& par) {
  if (u == par[u]) return u;
  return par[u] = find(par[u], par);
}
void merge(long long u, long long v, vector<long long>& par) {
  u = find(u, par);
  v = find(v, par);
  if (u != v) {
    if (u > v) swap(u, v);
    par[u] = v;
  }
}
long long m1, m2;
void solve(long long tc = 0) {
  cin >> n >> m1 >> m2;
  vector<long long> par1(n + 1), par2(n + 1);
  for (long long i = 1; i <= n; ++i) {
    par1[i] = i;
    par2[i] = i;
  }
  for (long long i = 1, x, y; i <= m1; ++i) {
    cin >> x >> y;
    merge(x, y, par1);
  }
  for (long long i = 1, x, y; i <= m2; ++i) {
    cin >> x >> y;
    merge(x, y, par2);
  }
  vector<pair<long long, long long> > res;
  for (long long i = 1; i <= n; ++i)
    for (long long j = i + 1; j <= n; ++j) {
      long long u1 = find(i, par1);
      long long v1 = find(j, par1);
      long long u2 = find(i, par2);
      long long v2 = find(j, par2);
      if (u1 != v1 and u2 != v2) {
        merge(u1, v1, par1);
        merge(u2, v2, par2);
        res.push_back({i, j});
      }
    }
  cout << (long long)res.size() << "\n";
  for (auto it : res) cout << it.first << " " << it.second << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  if (test) cin >> t;
  for (long long i = 1; i <= t; ++i) {
    solve(i);
  }
  return 0;
}
