// ~~ icebear ~~
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
template<class T>
    bool minimize(T &a, const T &b) {
        if (a > b) return a = b, true;
        return false;
    }
template<class T>
    bool maximize(T &a, const T &b) {
        if (a < b) return a = b, true;
        return false;
    }
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebear"
const int MOD = 1e9 + 7;
const int inf = 1e9 + 27092008;
const ll INF = 1e18 + 27092008;
const int N = 5e5 + 5;
int n, w[N], h[N];
vector<int> big[N], small[N];
ll area;
void init(void) {
    cin >> n;
    FOR(i, 1, n) {
        cin >> w[i] >> h[i];
        big[w[i]].pb(i);
        small[h[i]].pb(i);
        area += 1ll * w[i] * h[i];
    }
}
void process(void) {
    vector<int> ans;
    vector<bool> vis(n + 5, false);
    for(int i = 1; 1ll * i * i <= area; i++) if (area % i == 0) {
        FOR(i, 1, n) vis[i] = false;
        ll x = i, y = area / i;
        if (x < h[1]) continue;
        while(true) {
            if (x < y) swap(x, y);
            bool calc = false;
            if (x <= w[n]) {
                for(int i : big[x]) if (!vis[i]) {
                    vis[i] = true;
                    y -= w[i];
                    calc = true;
                }
            }
            if (calc) continue;
            for(int i : big[y]) if (!vis[i]) {
                vis[i] = true;
                x -= h[i];
                calc = true;
            }
            if (calc) continue;
            for(int i : small[y]) if (!vis[i]) {
                vis[i] = true;
                x -= w[i];
                calc = true;
            }
            if (!calc) break;
        }
        if (x * y == 0) ans.pb(i);
    }
    cout << ans.size() << '\n';
    for(int x : ans) cout << x << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    if (fopen(task".inp", "r")) {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    int tc = 1;
//    cin >> tc;
    while(tc--) {
        init();
        process();
    }
    return 0;
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:100:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  100 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:101:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  101 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |