#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;
ll power(ll a, ll b)
{
    ll value = 1;
    while (b)
    {
        if (b & 1)
        {
            value *= a;
        }
        a *= a;
        b /= 2;
    }
    return value;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll b[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    if(n==1){
        cout<<1<<endl<<b[0]<<endl;
        return 0;
    }
    ll a[n] = {0};
    a[0] = b[0];
    for (ll i = 1; i < n; i++)
    // {cout<<"& ";
        a[i] = b[i] - b[i - 1];
    // }cout<<"& ";
    int fg = 1, ans = -1;
    for (ll i = 1; i <=n-1; i++)
    {
        ll x = 0, k = i;
        fg=2;
        for (ll j = i; j < n; j++)
        {
            if (a[j] != a[(x++) % k])
            {
                fg = 1;
                break;
            }

        }
        if (fg == 2)
        {
            // cout<<" @ i "<<i<<endl;
            ans = i;
            fg=2;
            break;
        }
    }
    ll a1 = ans;
    vector<ll> v;
    // cout<<fg<<" ^^^"<<endl;
    if (fg == 2)
    {
        // cout<<"# ";
        while (ans <= n)
        {
            v.push_back(ans);
            ans += a1;
        }
        if (v[v.size() - 1] != n)
        {
            v.push_back(n);
        }
    }
    else
    {
        v.push_back(n);
    }
    cout << v.size() << endl;
    for (auto i : v)
    {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int >
#define eb emplace_back
#define all(v)  v.begin(),v.end()
#define pll pair<ll,ll>
#define mi map<int,int >
#define mll map<ll,ll>
#define mp make_pair
#define ll  long long int
#define vi vector<int >
#define vll vector< long long int >
#define rep(i,a,b) for(__typeof(b) i=a ;i<b;i++)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define in(i,a,b) __typeof(b) a[b]; for(__typeof(b) i=0;i<b;i++) cin>>a[i]

void solve(){
ll n;cin>>n;
ll a[n+1];a[0]=0;
rep(i,1,n+1)cin>>a[i];
vll res(n);
rep(i,0,n)
    res[i]=a[i+1]-a[i];
    int flag=1;vll r;
rep(i,1,n){ flag=1;
    for(int j=0;j<n;j+=i){
        if(j+i<n){
          if(res[j]==res[j+i])
             continue;
             else{flag=0; break;}
        }
    }if(flag)
    r.eb(i);
}
cout<<r.size()+1<<endl;
rep(i,0,r.size())cout<<r[i]<<" ";
cout<<n;
}
int main(){ io;
//int t;cin>>t;
//while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int >
#define eb emplace_back
#define all(v)  v.begin(),v.end()
#define pll pair<ll,ll>
#define mi map<int,int >
#define mll map<ll,ll>
#define mp make_pair
#define ll  long long int
#define vi vector<int >
#define vll vector< long long int >
#define rep(i,a,b) for(__typeof(b) i=a ;i<b;i++)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define in(i,a,b) __typeof(b) a[b]; for(__typeof(b) i=0;i<b;i++) cin>>a[i]

void solve(){
ll n;cin>>n;
ll a[n+1];a[0]=0;
rep(i,1,n+1)cin>>a[i];
vll res(n);
rep(i,0,n)
    res[i]=a[i+1]-a[i];
    int flag=1;vll r;
rep(i,1,n+1){ flag=1;
    for(int j=0;j<n;j+=i){
        if(j+i<n){
          if(res[j]==res[j+i])
             continue;
             else{flag=0; break;}
        }
    }if(flag)
    r.eb(i);
}
cout<<r.size()<<endl;
rep(i,0,r.size())cout<<r[i]<<" ";

}
int main(){ io;
//int t;cin>>t;
//while(t--)
solve();
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int >
#define eb emplace_back
#define all(v)  v.begin(),v.end()
#define pll pair<ll,ll>
#define mi map<int,int >
#define mll map<ll,ll>
#define mp make_pair
#define ll  long long int
#define vi vector<int >
#define vll vector< long long int >
#define rep(i,a,b) for(__typeof(b) i=a ;i<b;i++)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define in(i,a,b) __typeof(b) a[b]; for(__typeof(b) i=0;i<b;i++) cin>>a[i]

void solve(){
ll n;cin>>n;
ll a[n+1];a[0]=0;
rep(i,1,n+1)cin>>a[i];
vll res(n);
rep(i,0,n)
    res[i]=a[i+1]-a[i];
    int flag=1;vll r;
rep(i,1,n+1){ flag=1;
    for(int j=0;j<n;j++){
        if(j+i<n){
          if(res[j]==res[j+i])
             continue;
             else{flag=0; break;}
        }   else break;
    }if(flag)
    r.eb(i);
}
cout<<r.size()<<endl;
rep(i,0,r.size())cout<<r[i]<<" ";

}
int main(){ io;
//int t;cin>>t;
//while(t--)
solve();
return 0;
}


#include <bits/stdc++.h>
#define ll          long long int
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define mpll        map<ll,ll>
#define mpii        map<int,int>
#define vi          vector<ll>
#define vvi         vector<vi>
#define INF         1e9
#define bigMod      1000000007
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX =1e6+6;
ll arr[2000005],brr[2000005],crr[2000005];

int main()
{
    fastRead;
    int n,a;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        if(i==0)
        brr[i]=arr[i];
        else
        brr[i]=arr[i]-arr[i-1];
    }
    int cnt=1;
    for(int i=0;i<n-1;i++)
    {
        if(brr[i]==brr[i+1])
            cnt++;
    }
    if(cnt==n)
    {
        cout<<n<<endl;
        for(int i=1;i<=n;i++)
            cout<<i<<" ";
    }
    else
    {
        vector<int>v;
        v.push_back(n);
        int fd=brr[0];
        for(int i=1;i<n;i++)
        {
            if(fd==brr[i])
                v.push_back(i);
        }
        cout<<v.size()<<endl;
        sort(v.begin(),v.end());
        for(int i=0;i<v.size();i++)
            cout<<v[i]<<" ";
        cout<<endl;
    }
}


#include <bits/stdc++.h>
#define ll          long long int
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define mpll        map<ll,ll>
#define mpii        map<int,int>
#define vi          vector<ll>
#define vvi         vector<vi>
#define INF         1e9
#define bigMod      1000000007
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX =1e6+6;
ll arr[2000005],brr[2000005],crr[2000005];

int main()
{
    fastRead;
    int n,a;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        if(i==0)
            brr[i]=arr[i];
        else
            brr[i]=arr[i]-arr[i-1];
    }
    vector<int>v;
    v.push_back(n);
    int fd=brr[0];
    int k=1;
    for(int i=1; i<n; i++)
    {
        if(fd==brr[i])
        {
            int f=1;
            for(int j=i+1; j<n; j++)
            {
                if(brr[j]!=brr[k++])
                {
                    f=0;
                    break;
                }
            }
            if(f)
                v.push_back(i);
        }
    }
    cout<<v.size()<<endl;
    sort(v.begin(),v.end());
    for(int i=0; i<v.size(); i++)
        cout<<v[i]<<" ";
    cout<<endl;
    // }
}


#include <bits/stdc++.h>
#define ll          long long int
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define mpll        map<ll,ll>
#define mpii        map<int,int>
#define vi          vector<ll>
#define vvi         vector<vi>
#define INF         1e9
#define bigMod      1000000007
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX =1e6+6;
ll arr[2000005],brr[2000005],crr[2000005];

int main()
{
    fastRead;
    int n,a;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        if(i==0)
            brr[i]=arr[i];
        else
            brr[i]=arr[i]-arr[i-1];
    }
    vector<int>v;
    v.push_back(n);
    int fd=brr[0];
    for(int i=1; i<n; i++)
    {
        int k=1;
        if(fd==brr[i])
        {
            int f=1;
            for(int j=i+1; j<n; j++)
            {
                if(brr[j]!=brr[k++])
                {
                    f=0;
                    break;
                }
            }
            if(f)
                v.push_back(i);
        }
    }
    cout<<v.size()<<endl;
    sort(v.begin(),v.end());
    for(int i=0; i<v.size(); i++)
        cout<<v[i]<<" ";
    cout<<endl;

}


#include <bits/stdc++.h>
using namespace std;

typedef long long           ll;
typedef long double         ld;
typedef unsigned long long  ull;
typedef pair<ll,ll>         pll;

#define all(x)      x.begin(),x.end()
#define Sort(x)     sort(all(x))
#define sep         " "
#define fastio      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MAXN = 1001;
ll n, a[MAXN], k;
vector<ll> p, ans;

bool eq(vector<ll> a, vector<ll> b)
{
    for (ll i=0; i<min(a.size(),b.size()); i++){
        if (a[i]!=b[i]){
            return false;
        }
    }
    return true;
}

void draw(vector<ll> a)
{
    for (ll i : a){
        cout << i << sep;
    }
    cout << endl;
}

int main()
{
    fastio;
    cin >> n;
    for (ll i=1; i<=n; i++){
        cin >> a[i];
    }
    a[0] = 0;
    for (ll i=n; i>0; i--){
        a[i] = a[i] - a[i-1];
        //cout << i << sep << a[i] << endl;
    }
    for (ll j=1; j<=n; j++){
        p.push_back(a[j]);
        vector<ll> q;
        bool r = 1;
        for (ll l=j+1; l<=n; l+=j){
            for (ll o=l; o<l+j && o<=n; o++){
                q.push_back(a[o]);
            }
            //draw(q);
            if (!eq(p,q)){
                r = 0;
                break;
            }
        }
        if (r){
            ans.push_back(j);
        }
    }
    cout << ans.size() << endl;
    for (ll i:ans){
        cout << i << sep;
    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long           ll;
typedef long double         ld;
typedef unsigned long long  ull;
typedef pair<ll,ll>         pll;

#define all(x)      x.begin(),x.end()
#define Sort(x)     sort(all(x))
#define sep         " "
#define fastio      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MAXN = 1001;
ll n, a[MAXN], p[MAXN], q = 0;
vector<ll> vec;

int main()
{
    fastio;
    cin >> n;
    for (ll i = 0; i < n; i++){
        cin >> p[i];
        a[i] = p[i] - q;
        q = p[i];
    }

    for (ll i = 1; i < n; i++){
        bool r = 1;
        for(ll j = i; j < n; j++){
            if (a[j] != a[j-i])     r = 0;
        }
        if (r){
            vec.push_back(i);
        }
    }
    vec.push_back(n);

    cout << vec.size() << endl;
    for (ll i:vec){
        cout << i << sep;
    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long           ll;
typedef long double         ld;
typedef unsigned long long  ull;
typedef pair<ll,ll>         pll;

#define all(x)      x.begin(),x.end()
#define Sort(x)     sort(all(x))
#define sep         " "
#define fastio      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MAXN = 1001;
ll n, a[MAXN], k;
vector<ll> p, ans;

bool eq(vector<ll> a, vector<ll> b)
{
    for (ll i=0; i<min(a.size(),b.size()); i++){
        if (a[i]!=b[i]){
            return false;
        }
    }
    return true;
}

void draw(vector<ll> a)
{
    for (ll i : a){
        cout << i << sep;
    }
    cout << endl;
}

int main()
{
    fastio;
    cin >> n;
    for (ll i=1; i<=n; i++){
        cin >> a[i];
    }
    a[0] = 0;
    for (ll i=n; i>0; i--){
        a[i] = a[i] - a[i-1];
        //cout << i << sep << a[i] << endl;
    }
    for (ll j=1; j<=n; j++){
        p.push_back(a[j]);
        vector<ll> q;
        bool r = 1;
        for (ll l=j+1; l<=n; l+=j){
            for (ll o=l; o<=l+j && o<=n; o++){
                q.push_back(a[o]);
            }
            //draw(q);
            if (!eq(p,q)){
                r = 0;
                break;
            }
        }
        if (r){
            ans.push_back(j);
        }
    }
    cout << ans.size() << endl;
    for (ll i:ans){
        cout << i << sep;
    }
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 100000007
#define get(n) scanf("%d", &n)
#define getll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
    fast;
    int n;
    cin>>n;
    int a[n+1];
    a[0]=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    int l=n;
    int x[n+2];
    for(int i=1; i<=n; i++)
    {
        x[i-1]=(a[i]-a[i-1])+(l*i);
    }
    cout<<n<<endl;
    sort(x,x+n);
    for(int i=0;i<n;i++){
    cout<<x[i]<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 100000007
#define get(n) scanf("%d", &n)
#define getll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
    fast;
    int n;
    cin>>n;
    int a[n+1];
    a[0]=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    int l=n;
    int x[n+2];
    for(int i=1; i<=n; i++)
    {
        x[i-1]=(a[i]-a[i-1]);
    }
    cout<<n<<endl;
   // sort(x,x+n);
    for(int i=0;i<n;i++){
    cout<<x[i]<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 100000007
#define get(n) scanf("%d", &n)
#define getll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
    fast;
    int n;
    cin>>n;
    int a[n+1];
    a[0]=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    int l=n;
    int x[n+2];
    for(int i=1; i<=n; i++)
    {
        x[i-1]=(a[i]-a[i-1]);
    }
    cout<<n<<endl;
    sort(x,x+n);
    for(int i=0;i<n;i++){
    cout<<x[i]<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MOD 100000007
#define get(n) scanf("%d", &n)
#define getll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
    fast;
    int n;
    cin>>n;
    int a[n+1];
    int x[n+2];
    a[0]=0;
    vector<int>v;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        x[i-1]=(a[i]-a[i-1]);
    }
bool f=0;
for(int k=1; k<=n; k++)
{
    f=0;
    for(int i=0; i<n; i++)
    {

        if(x[i]!=x[i%k])
        {
            f=1;
            break;
        }
    }
        if(f!=1)v.pb(k);

}

cout<<v.size()<<endl;
sort(v.begin(),v.end());
// sort(x,x+n);
for(int i=0; i<v.size(); i++)
{
    cout<<v[i]<<" ";
}
return 0;
}


#include<iostream>
#include<string.h>
#include<set>
#include<map>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<deque>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<time.h>
#include<vector>
#include<iomanip>
using namespace std;
#define ll long long
#define FLAG if(flag)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define mp make_pair
#define pb push_back
#define fori(a,b) for(ll i=(a);i<=(b);++i)
#define foi(a,b) for(ll i=(b);i>=(a);--i)
#define forj(a,b) for(ll j=(a);j<=(b);++j)
#define fors(a,b) for(ll i=(a);i<(b);++i)
#define fos(a,b) for(ll i=(b-1);i>=(0);--i)
const ll mod=1e9+7;
//ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=ans*n;n=n*n;k>>=1;}return ans;}
ll INV(ll x){ return x==1?x:1LL*(mod-mod/x)*INV(mod%x)%mod; }
ll gcd(ll a,ll b){if(a<b)swap(a,b);return a%b==0?b:gcd(b,a%b);}
const ll MAX=1e6+10;
ll a[MAX];
ll b[MAX];
ll ans[MAX];
ll totol[MAX];
void in(ll y){for (ll i=1;i<=y;++i)scanf("%lld",&a[i]);}
void out(ll y){for (ll i=1;i<=y;++i){i==y?printf("%lld\n",a[i]):printf("%lld ",a[i]);}}
int main(){
ll n,k,m,sum,t,len,x,y;
string s,d;
//freopen("Ain.txt","r",stdin);
while(cin>>n){
     int flag=1;
     ans[0]=0;
     totol[0]=0;
     sum=0;
     t=0;
     len=s.size();
     y=0;
     set<ll>p;
     fori(0,n-1)
     {
         cin>>x;
         a[i]=x-t;
         t=x;
     }
     t=0;
     fori(0,n-1)
     {
         flag=1;
         forj(0,n-1)
         {
             if(a[j]!=a[j%(i+1)]){flag=0;break;}
         }
         if(flag){b[++t]=i+1;}
     }
     cout<<t<<endl;
     fori(1,t)cout<<b[i]<<' ';
     cout<<endl;
 }
//Can it be simplified or de-duplicated? n=1?n=0?Thinking about some special cases?
return 0;
}


#include<iostream>
#include<string.h>
#include<set>
#include<map>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<deque>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<time.h>
#include<vector>
#include<iomanip>
using namespace std;
#define ll long long
#define FLAG if(flag)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define mp make_pair
#define pb push_back
#define fori(a,b) for(ll i=(a);i<=(b);++i)
#define foi(a,b) for(ll i=(b);i>=(a);--i)
#define forj(a,b) for(ll j=(a);j<=(b);++j)
#define fors(a,b) for(ll i=(a);i<(b);++i)
#define fos(a,b) for(ll i=(b-1);i>=(0);--i)
const ll mod=1e9+7;
//ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=ans*n;n=n*n;k>>=1;}return ans;}
ll INV(ll x){ return x==1?x:1LL*(mod-mod/x)*INV(mod%x)%mod; }
ll gcd(ll a,ll b){if(a<b)swap(a,b);return a%b==0?b:gcd(b,a%b);}
const ll MAX=1e6+10;
ll a[MAX];
ll b[MAX];
ll ans[MAX];
ll totol[MAX];
void in(ll y){for (ll i=1;i<=y;++i)scanf("%lld",&a[i]);}
void out(ll y){for (ll i=1;i<=y;++i){i==y?printf("%lld\n",a[i]):printf("%lld ",a[i]);}}
int main(){
ll n,k,m,sum,t,len,x,y;
string s,d;
//freopen("Ain.txt","r",stdin);
while(cin>>n){
     int flag=1;
     ans[0]=0;
     totol[0]=0;
     sum=0;
     t=0;
     len=s.size();
     y=0;
     set<ll>p;
     fori(1,n)
     {
         cin>>x;
         a[i]=x-t;
         t=x;
     }
     t=0;
     fori(1,n)
     {
         b[i]=a[i];
         flag=1;
         forj(i+1,n)
         {
             b[j]=b[j%(i-1)];
             if(b[j]!=a[j]){flag=0;break;}
         }
         if(flag){t=i;break;}
     }
     if(t==0){
        cout<<1<<endl;
        cout<<n<<endl;
     }
     else{
            len=n;
        if(n%t)
        {
            n=n/t+1;
            fori(1,n-1)cout<<i*t<<' ';
            cout<<len<<endl;
        }
        else{
            n=n/t;
            fori(1,n)cout<<i*t<<' ';
            cout<<endl;
        }
     }
 }
//Can it be simplified or de-duplicated? n=1?n=0?Thinking about some special cases?
return 0;
}


#include<iostream>
#include<string.h>
#include<set>
#include<map>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<deque>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<time.h>
#include<vector>
#include<iomanip>
using namespace std;
#define ll long long
#define FLAG if(flag)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define mp make_pair
#define pb push_back
#define fori(a,b) for(ll i=(a);i<=(b);++i)
#define foi(a,b) for(ll i=(b);i>=(a);--i)
#define forj(a,b) for(ll j=(a);j<=(b);++j)
#define fors(a,b) for(ll i=(a);i<(b);++i)
#define fos(a,b) for(ll i=(b-1);i>=(0);--i)
const ll mod=1e9+7;
//ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=ans*n;n=n*n;k>>=1;}return ans;}
ll INV(ll x){ return x==1?x:1LL*(mod-mod/x)*INV(mod%x)%mod; }
ll gcd(ll a,ll b){if(a<b)swap(a,b);return a%b==0?b:gcd(b,a%b);}
const ll MAX=1e6+10;
ll a[MAX];
ll b[MAX];
ll ans[MAX];
ll totol[MAX];
void in(ll y){for (ll i=1;i<=y;++i)scanf("%lld",&a[i]);}
void out(ll y){for (ll i=1;i<=y;++i){i==y?printf("%lld\n",a[i]):printf("%lld ",a[i]);}}
int main(){
ll n,k,m,sum,t,len,x,y;
string s,d;
//freopen("Ain.txt","r",stdin);
while(cin>>n){
     int flag=1;
     ans[0]=0;
     totol[0]=0;
     sum=0;
     t=0;
     len=s.size();
     y=0;
     set<ll>p;
     fori(1,n)
     {
         cin>>x;
         a[i]=x-t;
         t=x;
     }
     t=0;
     fori(1,n)
     {
         flag=1;
         forj(1,n)
         {
             if(a[j]!=a[j%i+1]){flag=0;break;}
         }
         if(flag){t=i;break;}
     }
     if(t==0){
        cout<<1<<endl;
        cout<<n<<endl;
     }
     else{
            len=n;
        if(n%t)
        {
            n=n/t+1;
            cout<<n<<endl;
            fori(1,n-1)cout<<i*t<<' ';
            cout<<len<<endl;
        }
        else{
            n=n/t;
            cout<<n<<endl;
            fori(1,n)cout<<i*t<<' ';
            cout<<endl;
        }
     }
 }
//Can it be simplified or de-duplicated? n=1?n=0?Thinking about some special cases?
return 0;
}


#include<iostream>
#include<string.h>
#include<set>
#include<map>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<deque>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<time.h>
#include<vector>
#include<iomanip>
using namespace std;
#define ll long long
#define FLAG if(flag)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define mp make_pair
#define pb push_back
#define fori(a,b) for(ll i=(a);i<=(b);++i)
#define foi(a,b) for(ll i=(b);i>=(a);--i)
#define forj(a,b) for(ll j=(a);j<=(b);++j)
#define fors(a,b) for(ll i=(a);i<(b);++i)
#define fos(a,b) for(ll i=(b-1);i>=(0);--i)
const ll mod=1e9+7;
//ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=ans*n;n=n*n;k>>=1;}return ans;}
ll INV(ll x){ return x==1?x:1LL*(mod-mod/x)*INV(mod%x)%mod; }
ll gcd(ll a,ll b){if(a<b)swap(a,b);return a%b==0?b:gcd(b,a%b);}
const ll MAX=1e6+10;
ll a[MAX];
ll b[MAX];
ll ans[MAX];
ll totol[MAX];
void in(ll y){for (ll i=1;i<=y;++i)scanf("%lld",&a[i]);}
void out(ll y){for (ll i=1;i<=y;++i){i==y?printf("%lld\n",a[i]):printf("%lld ",a[i]);}}
int main(){
ll n,k,m,sum,t,len,x,y;
string s,d;
//freopen("Ain.txt","r",stdin);
while(cin>>n){
     int flag=1;
     ans[0]=0;
     totol[0]=0;
     sum=0;
     t=0;
     len=s.size();
     y=0;
     set<ll>p;
     fori(1,n)
     {
         cin>>x;
         a[i]=x-t;
         t=x;
         p.insert(a[i]);
     }
     if(n==1)
     {
         cout<<1<<endl;
         cout<<1<<endl;
         return 0;
     }
     t=0;
     set<ll>q;
     q.insert(a[1]);
     fori(2,n)
     {
         q.insert(a[i]);
         if(a[i]==a[1]&&q.size()==p.size()){t=i-1;break;}
     }
     if(t==0){
        cout<<1<<endl;
        cout<<n<<endl;
        return 0;
     }
     len=n;
     if(n%t)
     {
         n=n/t+1;
         cout<<n<<endl;
         fori(1,n-1)cout<<i*t<<' ';
         cout<<len<<endl;
     }
     else {
            n=n/t;
     cout<<n<<endl;
     fori(1,n)cout<<i*t<<' ';
     cout<<endl;
     }
 }
//Can it be simplified or de-duplicated? n=1?n=0?Thinking about some special cases?
return 0;
}


#include<iostream>
#include<string.h>
#include<set>
#include<map>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<deque>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<time.h>
#include<vector>
#include<iomanip>
using namespace std;
#define ll long long
#define FLAG if(flag)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define mp make_pair
#define pb push_back
#define fori(a,b) for(ll i=(a);i<=(b);++i)
#define foi(a,b) for(ll i=(b);i>=(a);--i)
#define forj(a,b) for(ll j=(a);j<=(b);++j)
#define fors(a,b) for(ll i=(a);i<(b);++i)
#define fos(a,b) for(ll i=(b-1);i>=(0);--i)
const ll mod=1e9+7;
//ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=ans*n;n=n*n;k>>=1;}return ans;}
ll INV(ll x){ return x==1?x:1LL*(mod-mod/x)*INV(mod%x)%mod; }
ll gcd(ll a,ll b){if(a<b)swap(a,b);return a%b==0?b:gcd(b,a%b);}
const ll MAX=1e6+10;
ll a[MAX];
ll b[MAX];
ll ans[MAX];
ll totol[MAX];
void in(ll y){for (ll i=1;i<=y;++i)scanf("%lld",&a[i]);}
void out(ll y){for (ll i=1;i<=y;++i){i==y?printf("%lld\n",a[i]):printf("%lld ",a[i]);}}
int main(){
ll n,k,m,sum,t,len,x,y;
string s,d;
//freopen("Ain.txt","r",stdin);
while(cin>>n){
     int flag=1;
     ans[0]=0;
     totol[0]=0;
     sum=0;
     t=0;
     len=s.size();
     y=0;
     set<ll>p;
     fori(0,n-1)
     {
         cin>>x;
         a[i]=x-t;
         t=x;
     }
     t=0;
     fori(0,n-1)
     {
         flag=1;
         forj(0,n-1)
         {
             if(a[j]!=a[j%(i+1)]){flag=0;break;}
         }
         if(flag){t=i+1;break;}
     }
     if(t==0){
        cout<<1<<endl;
        cout<<n<<endl;
     }
     else{
            len=n;
        if(n%t)
        {
            n=n/t+1;
            cout<<n<<endl;
            fori(1,n-1)cout<<i*t<<' ';
            cout<<len<<endl;
        }
        else{
            n=n/t;
            cout<<n<<endl;
            fori(1,n)cout<<i*t<<' ';
            cout<<endl;
        }
     }
 }
//Can it be simplified or de-duplicated? n=1?n=0?Thinking about some special cases?
return 0;
}


#include<iostream>
#include<string.h>
#include<set>
#include<map>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<deque>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<time.h>
#include<vector>
#include<iomanip>
using namespace std;
#define ll long long
#define FLAG if(flag)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define mp make_pair
#define pb push_back
#define fori(a,b) for(ll i=(a);i<=(b);++i)
#define foi(a,b) for(ll i=(b);i>=(a);--i)
#define forj(a,b) for(ll j=(a);j<=(b);++j)
#define fors(a,b) for(ll i=(a);i<(b);++i)
#define fos(a,b) for(ll i=(b-1);i>=(0);--i)
const ll mod=1e9+7;
//ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=ans*n;n=n*n;k>>=1;}return ans;}
ll INV(ll x){ return x==1?x:1LL*(mod-mod/x)*INV(mod%x)%mod; }
ll gcd(ll a,ll b){if(a<b)swap(a,b);return a%b==0?b:gcd(b,a%b);}
const ll MAX=1e6+10;
ll a[MAX];
ll b[MAX];
ll ans[MAX];
ll totol[MAX];
void in(ll y){for (ll i=1;i<=y;++i)scanf("%lld",&a[i]);}
void out(ll y){for (ll i=1;i<=y;++i){i==y?printf("%lld\n",a[i]):printf("%lld ",a[i]);}}
int main(){
ll n,k,m,sum,t,len,x,y;
string s,d;
//freopen("Ain.txt","r",stdin);
while(cin>>n){
     int flag=1;
     ans[0]=0;
     totol[0]=0;
     sum=0;
     t=0;
     len=s.size();
     y=0;
     fori(1,n)
     {
         cin>>x;
         a[i]=x-t;
         t=x;
     }
     if(n==1)
     {
         cout<<1<<endl;
         cout<<1<<endl;
         return 0;
     }
     t=0;
     fori(2,n)
     {
         if(a[i]==a[1]){t=i-1;break;}
     }
     if(t==0){
        cout<<1<<endl;
        cout<<n<<endl;
        return 0;
     }
     len=n;
     if(n%t)
     {
         n=n/t+1;
         cout<<n<<endl;
         fori(1,n-1)cout<<i*t<<' ';
         cout<<len<<endl;
     }
     else {
            n=n/t;
     cout<<n<<endl;
     fori(1,n)cout<<i*t<<' ';
     cout<<endl;
     }
 }
//Can it be simplified or de-duplicated? n=1?n=0?Thinking about some special cases?
return 0;
}


#include<iostream>
#include<string.h>
#include<set>
#include<map>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<deque>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<time.h>
#include<vector>
#include<iomanip>
using namespace std;
#define ll long long
#define FLAG if(flag)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define mp make_pair
#define pb push_back
#define fori(a,b) for(ll i=(a);i<=(b);++i)
#define foi(a,b) for(ll i=(b);i>=(a);--i)
#define forj(a,b) for(ll j=(a);j<=(b);++j)
#define fors(a,b) for(ll i=(a);i<(b);++i)
#define fos(a,b) for(ll i=(b-1);i>=(0);--i)
const ll mod=1e9+7;
//ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=ans*n;n=n*n;k>>=1;}return ans;}
ll INV(ll x){ return x==1?x:1LL*(mod-mod/x)*INV(mod%x)%mod; }
ll gcd(ll a,ll b){if(a<b)swap(a,b);return a%b==0?b:gcd(b,a%b);}
const ll MAX=1e6+10;
ll a[MAX];
ll b[MAX];
ll ans[MAX];
ll totol[MAX];
void in(ll y){for (ll i=1;i<=y;++i)scanf("%lld",&a[i]);}
void out(ll y){for (ll i=1;i<=y;++i){i==y?printf("%lld\n",a[i]):printf("%lld ",a[i]);}}
int main(){
ll n,k,m,sum,t,len,x,y;
string s,d;
//freopen("Ain.txt","r",stdin);
while(cin>>n){
     int flag=1;
     ans[0]=0;
     totol[0]=0;
     sum=0;
     t=0;
     len=s.size();
     y=0;
     set<ll>p;
     fori(1,n)
     {
         cin>>x;
         a[i]=x-t;
         t=x;
         p.insert(a[i]);
     }
     t=p.size();
    if(t==1){
        cout<<n<<endl;
        fori(1,n)cout<<i<<' ';
        cout<<endl;
    }
    else{
        fori(1,n)
        {
            if(a[i]==1&&a[i-1]>1)b[++y]=i-1;
        }
        b[++y]=n;
        cout<<y<<endl;
        fori(1,y)cout<<b[i]<<' ';
        cout<<endl;
    }
 }
//Can it be simplified or de-duplicated? n=1?n=0?Thinking about some special cases?
return 0;
}


#include<iostream>
#include<string.h>
#include<set>
#include<map>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<deque>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<time.h>
#include<vector>
#include<iomanip>
using namespace std;
#define ll long long
#define FLAG if(flag)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define mp make_pair
#define pb push_back
#define fori(a,b) for(ll i=(a);i<=(b);++i)
#define foi(a,b) for(ll i=(b);i>=(a);--i)
#define forj(a,b) for(ll j=(a);j<=(b);++j)
#define fors(a,b) for(ll i=(a);i<(b);++i)
#define fos(a,b) for(ll i=(b-1);i>=(0);--i)
const ll mod=1e9+7;
//ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans;}
ll qpow(ll n,ll k) {ll ans=1;while(k>0){if(k&1) ans=ans*n;n=n*n;k>>=1;}return ans;}
ll INV(ll x){ return x==1?x:1LL*(mod-mod/x)*INV(mod%x)%mod; }
ll gcd(ll a,ll b){if(a<b)swap(a,b);return a%b==0?b:gcd(b,a%b);}
const ll MAX=1e6+10;
ll a[MAX];
ll b[MAX];
ll ans[MAX];
ll totol[MAX];
void in(ll y){for (ll i=1;i<=y;++i)scanf("%lld",&a[i]);}
void out(ll y){for (ll i=1;i<=y;++i){i==y?printf("%lld\n",a[i]):printf("%lld ",a[i]);}}
int main(){
ll n,k,m,sum,t,len,x,y;
string s,d;
//freopen("Ain.txt","r",stdin);
while(cin>>n){
     int flag=1;
     ans[0]=0;
     totol[0]=0;
     sum=0;
     t=0;
     len=s.size();
     y=0;
     fori(1,n)
     {
         cin>>x;
         a[i]=x-t;
         t=x;
     }
     fori(2,n)
     {
         if(a[i]==1)b[++y]=i-1;
     }
     if(y<n)b[++y]=n;
     cout<<y<<endl;
     fori(1,y)cout<<b[i]<<' ';
     cout<<endl;
 }
//Can it be simplified or de-duplicated? n=1?n=0?Thinking about some special cases?
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{	int i,j=0,k,n,flag=0;
	cin>>n;
	vector<int> a(n,0);
	vector<int> x;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=n-1;i>=1;i--)
		a[i]=a[i]-a[i-1];
	for(k=1;k<=n;k++)
	{
		flag = 0;
		for(i=0;i<n;i++)
			if(a[i]!=a[i%k])
			{
				flag=1;
				break;
			}
		if(flag==0)
		{
			x.push_back(k);
		}
	}
	cout<<x.size() << "\n";
	for(i=0;i<x.size();i++)
		cout<<x[i] << " ";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{	int i,j=0,k,n,flag=0;
	cin>>n;
	vector<int> a(n,0);
	vector<int> x;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=n;i>=1;i--)
		a[i]=a[i]-a[i-1];
	for(k=1;k<=n;k++)
	{
		flag = 0;
		for(i=0;i<n;i++)
			if(a[i]!=a[i%k])
			{
				flag=1;
				break;
			}
		if(flag==0)
		{
			x.push_back(k);
		}
	}
	cout<<x.size() << "\n";
	for(i=0;i<x.size();i++)
		cout<<x[i] << " ";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define y1 dfsdsfsdfsd
#define next fdsfsdfjkl
#define endl "\n"
//#define int long long
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
double pi = acos(-1.0);
const int inf = 1e9+7;
const ll INF = 1e18+7;
/////////////////////////////////////////

int n;
int a[100100];
int x[100100];
vector<int>vi;

int used[100100];
int main(){speed;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];

    for(int k=1;k<=n;k++)
    {
        int ok = 0;

        for(int i=0;i<=10000;i++) used[i] = 0;

        for(int i=1;i<=n;i++)
        {
            int nw = a[i] - a[i-1];
            int ind = i%k;

            if(ind==0)
            {
                if(nw!=0)
                {
                    ok = 1;
                    break;
                }
            }
            else if(!used[ind]) used[ind] = nw;
            else
            {
                if(nw!=used[ind])
                {
                    ok=1;
                    break;
                }
            }
        }
        if(!ok)
        {
            vi.pb(k);
        }
    }

    cout<<vi.size()<<endl;
    for(int i=0;i<vi.size();i++) cout<<vi[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define y1 dfsdsfsdfsd
#define next fdsfsdfjkl
#define endl "\n"
//#define int long long
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
double pi = acos(-1.0);
const int inf = 1e9+7;
const ll INF = 1e18+7;
/////////////////////////////////////////

int n;
int a[100100];
int x[100100];
vector<int>vi;

int used[100100];
int main(){speed;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];

    for(int k=1;k<=n;k++)
    {
        int ok = 0;

        for(int i=0;i<=10000;i++) used[i] = inf;

        for(int i=1;i<=n;i++)
        {
            int nw = a[i] - a[i-1];
            int ind = (i-1)%k;

            if(used[ind]==inf) used[ind] = nw;
            else
            {
                if(nw!=used[ind])
                {
                    ok=1;
                    break;
                }
            }
        }
        if(!ok)
        {
            vi.pb(k);
        }
    }

    cout<<vi.size()<<endl;
    for(int i=0;i<vi.size();i++) cout<<vi[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define y1 dfsdsfsdfsd
#define next fdsfsdfjkl
#define endl "\n"
//#define int long long
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
double pi = acos(-1.0);
const int inf = 1e9+7;
const ll INF = 1e18+7;
/////////////////////////////////////////

int n;
int a[100100];
int x[100100];
vector<int>vi;

int used[100100];
int main(){speed;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];

    for(int k=1;k<=n;k++)
    {
        int ok = 0;

        for(int i=0;i<=10000;i++) used[i] = 0;

        for(int i=1;i<=n;i++)
        {
            int nw = a[i] - a[i-1];
            int ind = (i-1)%k;

            if(!used[ind]) used[ind] = nw;
            else
            {
                if(nw!=used[ind])
                {
                    ok=1;
                    break;
                }
            }
        }
        if(!ok)
        {
            vi.pb(k);
        }
    }

    cout<<vi.size()<<endl;
    for(int i=0;i<vi.size();i++) cout<<vi[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define y1 dfsdsfsdfsd
#define next fdsfsdfjkl
#define endl "\n"
//#define int long long
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
double pi = acos(-1.0);
const int inf = 1e9+7;
const ll INF = 1e18+7;
/////////////////////////////////////////

int n;
int a[100100];
int x[100100];
vector<int>vi;

int used[100100];
int main(){speed;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];

    for(int k=1;k<=n;k++)
    {
        int ok = 0;

        for(int i=0;i<=10000;i++) used[i] = inf;

        for(int i=1;i<=n;i++)
        {
            int nw = a[i] - a[i-1];
            int ind = (i)%k;

            if(used[ind]==inf) used[ind] = nw;
            else
            {
                if(nw!=used[ind])
                {
                    ok=1;
                    break;
                }
            }
        }
        if(!ok)
        {
            vi.pb(k);
        }
    }

    cout<<vi.size()<<endl;
    for(int i=0;i<vi.size();i++) cout<<vi[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define y1 dfsdsfsdfsd
#define next fdsfsdfjkl
#define endl "\n"
//#define int long long
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
double pi = acos(-1.0);
const int inf = 1e9+7;
const ll INF = 1e18+7;
/////////////////////////////////////////

int n;
int a[100100];
int x[100100];
vector<int>vi;

int used[100100];
int main(){speed;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];

    for(int k=1;k<=n;k++)
    {
        int ok = 0;

        for(int i=0;i<=10000;i++) used[i] = 0;

        for(int i=1;i<=n;i++)
        {
            int nw = a[i] - a[i-1];
            int ind = i%k;

            if(!used[ind]) used[ind] = nw;
            else
            {
                if(nw!=used[ind])
                {
                    ok=1;
                    break;
                }
            }
        }
        if(!ok)
        {
            vi.pb(k);
        }
    }

    cout<<vi.size()<<endl;
    for(int i=0;i<vi.size();i++) cout<<vi[i]<<" ";
}


#include <iostream>
#include <unordered_set>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;

#ifdef CODEFORCES_2019_02_25_3_H
int codeforces_2019_02_25_1() {
#else
int main() {
#endif
    int n;
    cin >> n;

    vector<ll> input;
    input.push_back(0);
    for (ll i = 0; i < n; i++) {
        ll temp;
        cin >> temp;
        input.push_back(temp);
    }

    vector<ll> res;
    for (ll i = 1; i < n; i++) {
        bool flag = true;
        ll diff = input[i] - input[0];
        for (ll j = 0; j < i; j++) {
            for (ll k = 1; k < n / i; k++) {
                if (input[j] != input[j + k * i] - diff * k) {
                    flag = false;
                    break;
                }
            }
        }
        for (int j = 0; j < n % i; j++) {
            if (input[input.size()-j-1] != input[input.size()-j-1-i] + diff) {
                flag = false;
                break;
            }
        }
        if (flag) {
            res.push_back(i);
        }
    }
    res.push_back(n);
    cout << res.size() << endl;
    for (auto elem : res)
        cout << elem << ' ';
    return 0;
}


#include <iostream>
#include <unordered_set>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;

#ifdef CODEFORCES_2019_02_25_3_H
int codeforces_2019_02_25_1() {
#else
int main() {
#endif
    int n;
    cin >> n;

    vector<ll> input;
    for (ll i = 0; i < n; i++) {
        ll temp;
        cin >> temp;
        input.push_back(temp);
    }

    vector<ll> res;
    for (ll i = 1; i < n; i++) {
        bool flag = true;
        ll diff = input[i] - input[0];
        for (ll j = 0; j < i; j++) {
            for (ll k = 1; k < n / i; k++) {
                if (input[j] != input[j + k * i] - diff * k) {
                    flag = false;
                    break;
                }
            }
        }
        for (int j = 0; j < n % i; j++) {
            if (input[input.size()-j-1] != input[input.size()-j-1-i] + diff) {
                flag = false;
                break;
            }
        }
        if (flag) {
            res.push_back(i);
        }
    }
    res.push_back(n);
    cout << res.size() << endl;
    for (auto elem : res)
        cout << elem << ' ';
    return 0;
}


#include <iostream>
#include <unordered_set>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;

#ifdef CODEFORCES_2019_02_25_3_H
int codeforces_2019_02_25_1() {
#else
int main() {
#endif
    ll n;
    cin >> n;

    vector<ll> input;
    input.push_back(0);
    for (ll i = 0; i < n; i++) {
        ll temp;
        cin >> temp;
        input.push_back(temp);
    }

    n++;
    vector<ll> res;
    for (ll i = 1; i < n; i++) {
        bool flag = true;
        ll diff = input[i] - input[0];
        for (ll j = 0; j < i; j++) {
            for (ll k = 1; k < n / i; k++) {
                if (input[j] != input[j + k * i] - diff * k) {
                    flag = false;
                    break;
                }
            }
        }
        for (ll j = 0; j < n % i; j++) {
            if (input[input.size()-j-1] != input[input.size()-j-1-i] + diff) {
                flag = false;
                break;
            }
        }
        if (flag) {
            res.push_back(i);
        }
    }
    cout << res.size() << endl;
    for (auto elem : res)
        cout << elem << ' ';
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <iterator>
#define ll long long
using namespace std;

int main()
{
	ll n, a[1000] = {}, x[1000] = {};
	vector<ll>A;
	cin >> n;
	for (ll i = 1; i <= n; i++)
		cin >> a[i], x[i - 1] = a[i] - a[i - 1];
	for (ll k = 1; k <= n; k++)
	{
		bool flag = 0;
		for (ll i = 1; i <= n; i++)
			if (a[i] != x[(i - 1) % k] + a[i - 1])
			{
				flag = 1;
				break;
			}
		if (!flag)
			A.push_back(k);
	}
	cout << A.size() << endl;
	copy(A.begin(), A.end(), ostream_iterator<ll>(cout, " "));
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <iterator>
#define ll long long
using namespace std;

int main()
{
	ll n, a[1001] = {}, x[1001] = {};
	vector<ll>A;
	cin >> n;
	for (ll i = 1; i <= n; i++)
		cin >> a[i], x[i - 1] = a[i] - a[i - 1];
	for (ll k = 1; k <= n; k++)
	{
		bool flag = 0;
		for (ll i = 1; i <= n; i++)
			if (a[i] != x[(i - 1) % k] + a[i - 1])
			{
				flag = 1;
				break;
			}
		if (!flag)
			A.push_back(k);
	}
	cout << A.size() << endl;
	copy(A.begin(), A.end(), ostream_iterator<ll>(cout, " "));
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <iterator>
#define ll long long
using namespace std;

int main()
{
	ll n, a[1000] = {}, x[1000] = {};
	vector<int>A;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i], x[i - 1] = a[i] - a[i - 1];
	for (int k = 1; k <= n; k++)
	{
		bool flag = 0;
		for (int i = 1; i <= n; i++)
			if (a[i] != x[(i - 1) % k] + a[i - 1])
			{
				flag = 1;
				break;
			}
		if (!flag)
			A.push_back(k);
	}
	cout << A.size() << endl;
	copy(A.begin(), A.end(), ostream_iterator<int>(cout, " "));
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <stack>
#include <map>
#include <math.h>
#include <set>
#include <vector>
#include <string>

using namespace std;
long long a[1000000];
long long x[1000000];
vector<int> answer;
int main() {
int n;
cin>>n;
for(int i=1;i<=n;i++){
	cin>>a[i];
}
a[0]=0;
for(int i=0;i<n;i++){
	x[i]=a[i+1]-a[i];
}

for(int k=1;k<=n;k++){
	int p=0;
for(int i=0;i<k;i++){
	for(int y=i+k;y<n;y+=k){
		if(x[y]!=x[y-k]){
		p=-1;
		break;
		}
	}
	if(p==-1)break;
}
if(p!=-1){
answer.push_back(k);
}
}
cout<<answer.size()<<endl;
for(int i=0;i<answer.size();i++){
	cout<<answer[i]<<" ";
}
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <stack>
#include <map>
#include <math.h>
#include <set>
#include <vector>
#include <string>

using namespace std;
long long a[1000000];
long long x[1000000];
int main() {
int n;
cin>>n;
for(int i=1;i<=n;i++){
	cin>>a[i];
}
a[0]=0;
for(int i=0;i<n;i++){
	x[i]=a[i+1]-a[i];
}

for(int k=1;k<=n;k++){
	int p=0;
for(int i=0;i<k;i++){
	for(int y=i+k;y<n;y+=k){
		if(x[y]!=x[y-k]){
		p=-1;
		break;
		}
	}
	if(p==-1)break;
}
if(p!=-1){
cout<<k<<" ";
}
}

}


#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
int ans[1005];
int a[1005];
int cnt=0;
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int i;
    for (i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for (i=n-1;i>=1;i--)
    {
        a[i]-=a[i-1];
    }
    for (i=1;i<=n;i++)
    {
        int j;
        for (j=0;j<n;j++)
        {
            if (a[j]!=a[j%i])
            {
                break;
            }
        }
        if (j==n)
        {
            ans[cnt++]=i;
        }
    }
    printf("%d\n",cnt);
    for (i=0;i<cnt;i++)
    {
        printf("%d ",ans[i]);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int n;
int a[1111];
int b[1111];
vector<int> answ;
int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; ++i)
    {
        scanf("%d",a+i+1);
        b[i] = a[i+1] - a[i];
    }
    for(int k = 1; k <= n; ++k)
    {
        bool ok = true;
        for(int i = 0; i + k < n; ++i)
            if(b[i] != b[i + k])
            {
                ok = false;
                break;
            }
        if(ok)
            answ.push_back(k);
    }
    printf("%d\n", answ.size());
    for(int i=0; i<answ.size(); ++i)
        printf("%d ", answ[i]);
    return 0;
}


#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
	int n;
	vector<int> a;
	vector<int>m;
	cin >> n;
	a.resize(n + 1);
	a[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int k = 1;
	for (int i = 1; i <= n; i++) {
		int counter = 0;
		vector<int>r;
		for (int j = 1; j <= k; j++) {
			r.push_back(a[j] - a[j - 1]);
		}
		for (int j = 1; j < n+1; j++) {
			if (a[j] - a[j - 1] == r[(j-1) % k]) {
				counter++;
			}
			else {
				break;
			}
		}
		if (counter == n) {
			m.push_back(k);
			k++;
		}
		else{
			k++;
		}
	}
	sort(m.begin(), m.end());
	cout << m.size() << "\n";
	for (int i = 0; i < m.size(); i++) {
		cout << m[i] << " ";
	}
	//system("pause>nul");
	return 0;
}


#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#define __USE_MINGW_ANSI_STDIO 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#include<string>
#include<map>
#include<bitset>
#include <math.h>
#include<queue>
#include<complex>
#include<ctime>
#include<cctype>
#include<list>
#define ll long long
#define is_bit(a,b) (a&(1<<b))
using namespace std;
int n;
int a[1001];
int aa[1001];
vector<int> ans;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
 //freopen("four.in", "r", stdin);
 //freopen("four.out", "w", stdout);
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int k=1;k<=n;k++)
{
    bool ok=true;
    vector<int> x;
    x.push_back(a[1]);
    for(int i=2;i<=k;i++)
    x.push_back(a[i]-a[i-1]);
    for(int i=1;i<=n;i++)
    {
        aa[i]=aa[i-1]+x[(i-1)%k];
        if(a[i]!=aa[i])
        ok=false;
    }
    if(ok)
    ans.push_back(k);
}
cout<<ans.size()<<"\n";
for(int i=0;i<ans.size();i++)
cout<<ans[i]<<" ";
  return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <cstring>
#include <fstream>
#define ll long long int
using namespace std;
const double _pi = acos(-1.0);
int ar[1010];
int ar2[1010];
int main()
{
    //freopen("in.txt", "r", stdin);
	vector<int> res;
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &ar[i]);
	}
	for(int i = 1; i <= n; i++)
	{
		bool b = true;
		for(int j = 1; j <= n; j++)
		{
			if((j - 1) / i == 0) ar2[j-1] = ar[j] - ar[j-1];
			else
			{
				if(ar2[(j-1) % i] == (ar[j] - ar[j-1])) ar2[j-1] = ar[j] - ar[j-1];
				else
				{
					b = false;
					break;
				}

			}
		}
		if(b) res.push_back(i);
	}
	printf("%d\n", res.size());
	for(int i = 0; i < res.size(); i++)
	{
		if(i == res.size() - 1) printf("%d\n", res[i]);
		else printf("%d ", res[i]);
	}
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<set>
#include<vector>
#include<list>
using namespace std;

int main()
{
	long long int n, a;
	cin >> n;
	vector<long long int> vct, difArray, ResultVector;
	vct.push_back(0);
	for (auto i = 0;i < n;i++)
	{
		cin >> a;
		vct.push_back(a);
	}
	//difArray.push_back(vct[0] - 0);
	for (auto i = 1;i <= n;i++)
	{
		long long int diff = vct[i] - vct[i-1];
		difArray.push_back(diff);
	}
	long long int lencount = 0;

	for (auto len = 1; len<= n;len++)
	{
		bool IsAnswer = true;
		for (auto j = 1;j <= n;j++)
		{
			long long int Index = (j-1)%len;
			long long int diff = vct[j] - vct[j - 1];
			if (diff != difArray[Index])
			{
				IsAnswer = false;
				break;
			}
		}
		if (IsAnswer)
		{
			lencount++;
			ResultVector.push_back(len);
		}
	}

	cout << lencount << endl;
	for (int i = 0;i < ResultVector.size();i++)
		cout << ResultVector[i] << " ";

	return 0;

}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	int a, aprev = 0;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		x[i] = a - aprev;
		aprev = a;
	}
	int length = 1;
	for (int i = 1; i < n; i++)
	{
		if (x[i - length] != x[i])
		{
			length++;
			i = length;
		}
	}
	int count = n / length + (n % length == 0 ? 0 : 1);
	cout << count << endl;
	for (int i = 1; length * i < n; i++)
		cout << length * i << " ";
	cout << n;
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	int a, aprev = 0;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		x[i] = a - aprev;
		aprev = a;
	}
	int length = 1;
	for (int i = 1; i < n;)
	{
		if (x[i - length] != x[i])
		{
			length++;
			i = length;
		}
		else i++;
	}
	int count = n / length + (n % length == 0 ? 0 : 1);
	cout << count << endl;
	for (int i = 1; length * i < n; i++)
		cout << length * i << " ";
	cout << n;
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	int a, aprev = 0;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		x[i] = a - aprev;
		aprev = a;
	}
	int length = 1;
	for (int i = 1; i < n;)
	{
		if (x[i % length] != x[i])
		{
			length++;
			i = length;
		}
		else i++;
	}
	int count = n / length + (n % length == 0 ? 0 : 1);
	cout << count << endl;
	for (int i = 1; length * i < n; i++)
		cout << length * i << " ";
	cout << n;
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	int a, aprev = 0;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		x[i] = a - aprev;
		aprev = a;
	}

	vector<int> l;
	int length = 0;
	for (int length = 1; length <= n; length++)
	{
		bool f = true;
		for (int i = 1; i < n && f; i++)
		{
			if (x[i % length] != x[i])
				f = false;
		}
		if (f) l.push_back(length);
	}

	cout << l.size() << endl;
	for (int i = 0; i < l.size(); i++)
		cout << l[i] << " ";
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	int a, aprev = 0;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		x[i] = a - aprev;
		aprev = a;
	}
	int length = 1;
	for (int i = 1; i < n; i++)
	{
		if (x[i - length] != x[i])
			length = i + 1;
	}
	int count = n / length + (n % length == 0 ? 0 : 1);
	cout << count << endl;
	for (int i = 1; length * i < n; i++)
		cout << length * i << " ";
	cout << n;
	return 0;
}


#include<cstdio>
#include<vector>

using namespace std;

int main()
{
	int n, m;
	vector<int> arr;
	vector<int> cand[2];
	vector<bool> erase;
	int i, j;
	int input;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &input);

		arr.push_back(input);
	}

	arr.insert(arr.begin(), 0);

	cand[1].push_back(1);

	for (i = 1; i < n; i++)
	{
		for (j = 0; j < cand[i%2].size(); j++)
		{
			if (arr[i - cand[i % 2][j]] - arr[i - cand[i % 2][j] + 1] != arr[i] - arr[i + 1])
			{
				erase.push_back(true);
			}

			else
			{
				erase.push_back(false);
			}
		}

		for (j = 0; j < cand[i % 2].size(); j++)
		{
			if (!(erase[j]))
			{
				cand[!(i % 2)].push_back(cand[i % 2][j]);
			}
		}

		cand[!(i % 2)].push_back(i + 1);

		cand[i % 2].clear();
		erase.clear();
	}

	//cand[(n % 2)].push_back(n);

	printf("%d\n", cand[(n % 2)].size());

	for (i = 0; i < cand[(n % 2)].size(); i++)
	{
		printf("%d ", cand[(n % 2)][i]);
	}

	return 0;
}


#include<string>
#include<vector>
#include<iostream>
using namespace std;
#define sp << " "
#define sps << " " <<
#define lnl << endl <<
#define ln << endl
#define vi vector<int>
#define vc vector<char>
#define vll vector<ll>
#define pb push_back
#define pop pop_back
#define forin for(int i = 0; i < n; ++i)
#define forim for(int i = 0; i < m; ++i)
#define forik for(int i = 0; i < k; ++i)
#define pii pair<int, int>
#define piii pair<pii, int>
typedef long long ll;
typedef double llf;
using namespace std;
//FUNCTIONS
ll nod(ll a, ll b) { while (a != 0 && b != 0)if (a > b)a %= b; else b %= a; return a + b; }//НОД двух чисел
ll nok(ll a, ll b) { return (a * b) / nod(a, b); }//НОК двух чисел
void reverse(string &a, int l, int r) { for (int i = l; i <= (l + r) / 2; ++i)swap(a[i], a[r - i + l]); }//переворот отрезка массива
int irand(int a, int b) { return rand() % (b - a + 1) + a; }//генерация рандомного числа на отрезкe a...b
int fib(int n) { if (n < 3) return 1; return fib(n - 1) + fib(n - 2); }//n-ное число Фиббоначи
ll binpow(ll a, ll n) { if (n == 0)return 1; if (n % 2 == 1)return binpow(a, n - 1)*a; else return binpow(a*a, n / 2); }//быстрая степень
bool isprime(ll a) { for (int i = 2; i*i <= a; ++i)if (a%i == 0)return false; return true; }//проверка на простое число
void main()
{
	int i,m=0,cnt=0,n;
	cin>>n;
	vector<int>a(n+1);
	vector<int>b(n+1);
	vector<int>c(n+1);
	bool bk;
	a[0]=0;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=n-1;i>=0;i--)
		b[i]=a[i+1]-a[i];
	for(int k=1;k<=n;k++)
	{
		bk=true;
		for(i=1;i<n;i++)
		{
			if(b[i]!=b[i%k])
			{
				bk=false;
				break;
			}
		}
		if(bk)
		{
			c[cnt]=k;
			cnt++;
		}
	}
	cout<<cnt ln;
	for(i=0;i<cnt;i++)
		cout<<c[i] sp;
}


#include<iostream>
#include<fstream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>
#include<stdio.h>
#include <math.h>
#include <stack>
#define int long long
using namespace std;

int a[100000];
int x[100000];
void main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		x[i - 1] = a[i] - a[i - 1];
	}
	vector<int>ans;
	for (int i = 0; i < n; i++)
	{
		bool ok = true;
		for (int j = i + 1; j < n; j++)
		{
			if (x[j] != x[j-i-1])
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			ans.push_back(i + 1);
		}
	}
	cout << ans.size()<<"\n";
	for (int i = 0; i < ans.size(); i++)
	{
		cout << ans[i] << " ";
	}
}


#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;

//int pos(vector<int> s, vector<int> c, int n)
//{
//	int i, j;
//	int lenC = c.size(), lenS = s.size();
//
//	for (i = 0; i <= lenS - lenC; i++)
//	{
//		for (j = 0; s[i + j] == c[j]; j++);
//		if (j - lenC == 1 && i == lenS - lenC && !(n - 1)) return i;
//		if (j == lenC)
//			if (n - 1) n--;
//			else return i;
//	}
//	return -1;
//}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n+1);
	a[0] = 0;
	for (int i = 1; i < n+1; i++)
	{
		cin >> a[i];
	}

	vector<int> x(n);
	for (int i = 1; i < n+1; i++)
	{
		x[i - 1] = a[i - 1] - a[i];
	}

	// перебор всех подстрок (поиск циклов) до i <= n/2
	vector<int> c;
	int i, j;
	vector<int> lens;
	int lenC;
	for (i = 0; i < n; i++)
	{
		c.push_back(x[i]);
		lenC = c.size();
		for (j = 0; j < n; j++)
		{
			if (x[j] == c[j%lenC])
				continue;
			else break;
		}
		if (j == n)
		{
			lens.push_back(lenC);
		}
	}

	int L = lens.size();
	cout << L << endl;
	for (int i = 0; i < L; i++)
	{
		cout << lens[i] << " ";
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int>arr(n+1);
	vector<int>arr1(n+1);
	vector<int>ans(n);
	arr[0] = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	//cout << arr1[0] << " ";
	for (int i = 1; i <= n; i++)
	{
		arr1[i] = arr[i] - arr[i - 1];
		//cout << arr1[i] << " ";
	}
	int sum = 0;
	int id = 0;
	bool check;
	int k = 0;
	for (int high = 1; high <= n; high++)
	{
		for (int i = 1; i <= n; i++)
		{
			check = true;
			if (i + high <= n)
			{
				if (arr1[i] != arr1[i + high])
				{

					check = false;
					break;
				}
			}

		}
		if (check)
		{
			sum++;
			ans[id] = high;
			id++;
			//cout << high<<" "<<id<<" ";
		}

	}
	//cout << '\n';
	cout << sum<<'\n';
	//cout << id << " ";
	for (int i = 0; i < id; i++)
	{
		cout << ans[i]<<" ";
	}
	//	system("pause");
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> v(n);
	int last=0;
	for (size_t i = 0; i < n; i++)
	{
		int x; cin >> x;
		v[i] = x - last;
		last = x;
	}
	vector<int> ans;
	for (int j = 1; j < n; j++)
	{
		bool ok = 1;
		for (int i = 0; i+j < n; i++)
		{
			if (v[i] != v[i + j])
			{
				ok = 0;
				break;
			}

		}
		if (ok) ans.push_back(j);
	}
	ans.push_back(n);
	cout << ans.size() << endl;
	for (size_t i = 0; i < ans.size(); i++)
	{
		cout << ans[i]<<" ";

	}
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 2000

int main(){
	int a[N];
	f(i, N)a[i] = 0;
	vector<int>b;
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	y = 0;
	f(i, n){
		scanf("%d", &x);
		a[i] = x - y;
		y = x;
	}
	for(int i=1;i<=n;i++){
		v = true;
		f(j, n){
			x = j%i;
			if (a[x] != a[j]){
				v = false;
				break;
			}
		}
		if (v)b.push_back(i);
	}

	printf("%d\n", b.size());
	f(i, b.size()){
		printf("%d", b[i]);
		if (i < b.size() - 1)printf(" ");
		else printf("\n");
	}

	return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <queue>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <float.h>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vp;
typedef vector<string> vs;
typedef set<int> si;
typedef map<int, int> mi;
typedef map<ll, ll> ml;

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vi a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	for (int i = n - 1; i > 0; --i)
		a[i] -= a[i - 1];

	vb vk(n);
	for (int k = 1; k <= n; ++k)
	{
		bool ok = true;
		for (int i = 0; i < n; ++i)
		{
			if (a[i] != a[i % k])
			{
				ok = false;
				break;
			}
		}
		if (ok)
			vk[k - 1] = true;
	}

	int res = 0;
	for (int k = 0; k < n; ++k)
		if (vk[k])
			++res;
	cout << res << endl;
	for (int k = 0; k < n; ++k)
		if (vk[k])
			cout << k + 1 << " ";
	cout << endl;

	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

bool isRazn(vector<int> mas, int d, int n) {
	for (int i = 0; i+d < n; i++)
	{
		if (mas[i] != mas[i + d])
			return false;
	}
	return true;
}

int main() {
	int n; cin >> n;
	vector<int> v;
	//v.resize(n + 1);
	v.push_back(0);

	for (int i = 0; i < n; i++)
	{
		int buf;
		cin >> buf;
		v.push_back(buf);
	}

	vector<int> razn;
	for (int i = 1; i < v.size(); i++)
	{
		razn.push_back(v[i] - v[i - 1]);
	}

	vector<int> ans;
	for (int i = 1; i < n+1; i++)
	{
		if (isRazn(razn,i,razn.size()))
			ans.push_back(i);
	}
	cout << ans.size()<<endl;
	for (int i = 0; i < ans.size(); i++)
	{
		cout << ans[i] << " ";
	}
	cout<<endl;

	//cin >> n;
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <utility>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 1);
	vector<int> v(n);
	a[0] = 0;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		v[i - 1] = a[i] - a[i - 1];
	}
	string s;
	for (int i = 0; i < n; ++i)
	{
		s.push_back(v[i] + '0');
	}
	n += 1;
	vector<int> w;
	for (int j = 1; j < n; ++j)
	{
		bool f = true;
		for (int i = 0; i < n - 1 - j; ++i)
		{
			if (s[i] != s[i + j])
			{
				f = false;
			}
		}
		if (f)
		{
			w.push_back(j);
		}
	}
	cout << w.size() << endl;
	for (int i = 0; i < w.size(); ++i)
	{
		cout << w[i] << ' ';
	}
	cout << endl;
}


#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    vector <int> a(n), d(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(i > 0){
            d[i] = a[i] - a[i - 1];
        }
        else{
            d[i] = a[i];
        }
    }
    vector <int> ans;
    for (int i = 1; i <= n; i++){
        bool ok = true;
        for(int j = i; j < n; j++){
            if(d[j] != d[j - i]){
                ok = false;
                break;
            }
        }
        if(ok){
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << " ";
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <set>
#include <fstream>
using namespace std;

#define ll long long

int main(){
	ll n, m, a, b, c;
	cin >> n;
	vector <ll> ch(2000);
	vector <ll> ch1(2000);
	vector <ll> res;
	for (int i = 0; i < n; i++)
		cin >> ch[i];
	ch1[0] = ch[0];
	for (int i = 1; i < n; i++){
		ch1[i] =  ch[i] - ch[i-1];
	}
	for (int i = 1; i < n; i++){
		ll chk = 1;
		ll j = i;
		while ((j < n) && (chk == 1)){
			if (ch1[j - i] != ch1[j])
				chk = 0;
			j++;
		}
		if (chk == 1)
			res.push_back(i);
	}
	res.push_back(n);
	cout << res.size() << endl;
	for (int i = 0; i < res.size(); i++)
		cout << res[i] << " ";
}


#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<vector>
#define MAXN 0x7fffffff
typedef long long LL;
const int N=2005,M=13,mod=1e9+7;
using namespace std;
inline int Getint(){register int x=0,f=1;register char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}return x*f;}
int n,m,h[N];
struct Edge{int to,next;}g[N<<1];
void AddEdge(int x,int y){static int cnt=0;g[++cnt].to=y,g[cnt].next=h[x],h[x]=cnt;}

int rd[M],mp[M][M];
int to[1<<M],cnt[1<<M];
int tmp[1<<M],f[N][1<<M],w[M][1<<M];
vector<int>tran[1<<M];
void Dfs1(int x,int fa){
	f[x][0]=1;
	for(int i=1;i<=m;i++)f[x][1<<i-1]=1;
	for(int i=h[x];i;i=g[i].next){
		int to=g[i].to;
		if(to==fa)continue;
		Dfs1(to,x);
		memcpy(tmp,f[x],sizeof(f[x]));
		memset(f[x],0,sizeof(f[x]));
		for(int j=0;j<(1<<m);j++){
			if(::to[j]<0||!tmp[j])continue;
			for(int k=0;k<tran[j].size();k++){
				int p=tran[j][k];
				f[x][j|p]=(f[x][j|p]+(LL)tmp[j]*f[to][p])%mod;
			}
		}
	}
}
void Dfs2(int x,int fa){
	w[x][0]=1;
	for(int i=1;i<=m;i++)w[x][1<<i-1]=1;
	for(int to=1;to<=m;to++){
		if(!mp[x][to]||to==fa)continue;
		Dfs2(to,x);
		memcpy(tmp,w[x],sizeof(w[x]));
		memset(w[x],0,sizeof(w[x]));
		for(int j=0;j<(1<<m);j++){
			if(::to[j]<0||!tmp[j])continue;
			for(int k=0;k<tran[j].size();k++){
				int p=tran[j][k];
				w[x][j|p]=(w[x][j|p]+(LL)tmp[j]*w[to][p])%mod;
			}
		}
	}
}
int ksm(int x,int k){
	int ret=1;
	while(k){
		if(k&1)ret=(LL)ret*x%mod;
		x=(LL)x*x%mod,k>>=1;
	}
	return ret;
}
int main(){
	n=Getint();
	for(int i=1;i<n;i++){
		int x=Getint(),y=Getint();
		AddEdge(x,y),AddEdge(y,x);
	}
	m=Getint();
	for(int i=1;i<m;i++){
		int x=Getint(),y=Getint();
		mp[x][y]=mp[y][x]=1;
		rd[x]++,rd[y]++;
	}
	for(int S=0;S<(1<<m);S++){
		int tmp[M];
		memcpy(tmp,rd,sizeof(rd));
		for(int i=1;i<=m;i++){
			if(!(S&(1<<i-1)))continue;
			for(int j=i+1;j<=m;j++)
				if(S&(1<<j-1)&&mp[i][j])
					tmp[i]--,tmp[j]--;
		}
		int pos=0;
		for(int i=1;i<=m;i++)
			if(S&(1<<i-1)&&tmp[i]>0)pos=pos?-1:i;
		to[S]=pos,cnt[S]=tmp[pos];
	}
	int S=(1<<m)-1;
	tran[0].push_back(S);
	for(int i=0;i<(1<<m);i++){
		if(to[i]<0)continue;
		tran[i].push_back(0);
		for(int j=S^i;j;j=(j-1)&(S^i)){
			if(to[j]<0||!mp[to[i]][to[j]]||to[i|j]<0||cnt[j]>1)continue;
			tran[i].push_back(j);
		}
	}
	Dfs1(1,0),Dfs2(1,0);
	cout<<(LL)f[1][S]*ksm(w[1][S],mod-2)%mod;
	return 0;
}


/// by ztx
/// blog.csdn.net/hzoi_ztx
/// learnt from myy  (matthew99:http://codeforces.com/contest/762/submission/24128833)
#include <bits/stdc++.h>
#define Rep(i,l,r) for(i=(l);i<=(r);i++)
#define rep(i,l,r) for(i=(l);i< (r);i++)
#define r(x)   read(x)
typedef long long ll ;
int CH , NEG ;
template <typename TP>inline void read(TP& ret) {
    ret = NEG = 0 ; while (CH=getchar() , CH<'!') ;
    if (CH == '-') NEG = true , CH = getchar() ;
    while (ret = ret*10+CH-'0' , CH=getchar() , CH>'!') ;
    if (NEG) ret = -ret ;
}
using namespace std;
#define  kN   1000LL
#define  kM   12LL
#define  pb   push_back
#define  kMod 1000000007LL

int n, m, ANS;
int now[(1<<kM)+5], nxt[(1<<kM)+5];
vector<int> G[kN+5], g[kM+5];
map<int,vector<int> > STA;
map<int,int> ans[kN+5];

inline int blen(int x) { return 32 - __builtin_clz(x); } // __builtin_clz()   count leading zeros
inline int combine(int x, int y) { return x << blen(y) | y; }

inline void P(int x) {
    for (int i = 30; ~i; i -- ) { printf("%d",int(bool(x&(1<<i)))); } puts("");
}

int dfs0(int u,int fa = 0) {
    int h = 1;
    vector<int> H;
    for (auto v : g[u]) if (v != fa) H.pb(dfs0(v,u));
    sort(H.begin(), H.end());
    // minimum representation of tree
    for (auto s : H) h = combine(h,s);
    h <<= 1;
//printf("h[%d] = ",u);
//P(h);
    if (!STA.count(h)) STA[h] = H;
    return h;
}

void dfs(int u,int fa = 0) {
    vector<int> chd;
    for (auto v : G[u]) if (v != fa) chd.pb(v), dfs(v,u);
    for (const auto &sta : STA) {
        auto &H = sta.second;
        int h = sta.first, N = H.size();
        memset(now, 0, sizeof(int)*(1<<N));
        now[0] = 1;
        for (auto ch : chd) {
            memcpy(nxt, now, sizeof(int)*(1<<N));
            for (int i = 0; i < N; i ++ ) {
                int num = ans[ch][H[i]];
                if (!num) continue;
                for (int j = (1<<N)-1; j >= 0; j -- )
                    if (now[j] && !(j>>i & 1) && !(i && H[i]==H[i-1] && !(j>>(i-1) & 1)))
                        (nxt[j|(1<<i)] += (ll)now[j]*num%kMod) %= kMod;
            }
            memcpy(now, nxt, sizeof(int)*(1<<N));
        }
        if (now[(1 << N) - 1]) {
            ans[u][h] = now[(1 << N) - 1];
            if (blen(h) == (m<<1)) (ANS += now[(1<<N)-1]) %= kMod;
        }
    }
}

int main() {
    int i, u, v;
    r(n);
    rep (i,1,n)
        r(u), r(v), G[u].pb(v), G[v].pb(u);
    r(m);
    rep (i,1,m)
        r(u), r(v), g[u].pb(v), g[v].pb(u);
    Rep (i,1,m) dfs0(i);
    dfs(1);
    (ANS += kMod) %= kMod;
    printf("%d\n", ANS);
    END: getchar(), getchar();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1001;
const int MAXV = 1 << 12;
const int mod = 1e9 + 7;

inline int Pow(int x, int y)
{
	int s = 1;
	for( ; y ; y >>= 1, x = 1ll * x * x % mod ) if( y & 1 ) s = 1ll * s * x % mod;
	return s;
}

inline int inv(int x) { return Pow( x, mod - 2 ); }

struct edge { int to, nxt; };

struct tree
{
	edge e[MAXN << 1];
	int n, cnt;
	int head[MAXN], son[MAXN][MAXN], size[MAXN], bit[MAXN];
	inline void addedge(int x, int y) { e[ ++cnt ].to = y; e[ cnt ].nxt = head[ x ]; head[ x ] = cnt; }
	inline void read()
	{
		scanf( "%d", &n );
		for( int i = 1 ; i < n ; i++ ) { int x, y; scanf( "%d%d", &x, &y ); addedge( x, y ); addedge( y, x ); }
	}
	inline void dfs(int x, int fa)
	{
		size[ x ] = bit[ x ] = 0;
		for( int i = head[ x ] ; i ; i = e[ i ].nxt ) if( e[ i ].to ^ fa )
			dfs( son[ x ][ ++size[ x ] ] = e[ i ].to, x ), bit[ x ] |= 1 << e[ i ].to - 1;
	}
}S, T;

int dp[MAXN][MAXV], ans, ans2;

bool vis[MAXN][MAXV];

inline int dfs(int f, int y, int V)
{
	if( !y ) return !V;
	int x = S.son[ f ][ y ];
	if( vis[ x ][ V ] ) return dp[ x ][ V ];
	vis[ x ][ V ] = 1;
	int &ret = dp[ x ][ V ];
	ret = dfs( f, y - 1, V );
	for(int i = 0 ; i < T.n ; i++ ) if( V >> i & 1 )
		ret = ( 1ll * dfs( f, y - 1, V ^ ( 1 << i ) ) * dfs( x, S.size[ x ], T.bit[ i + 1 ] ) + ret ) % mod;
	return ret;
}

int main()
{
	S.read();
	T.read();
	S.dfs( 1, 0 );
	for( int i = 1 ; i <= T.n ; i++ )
	{
		memset( dp, 0, sizeof dp );
		memset( vis, 0, sizeof vis );
		T.dfs( i, 0 );
		for( int j = 1 ; j <= S.n ; j++ ) ( ans += dfs( j, S.size[ j ], T.bit[ i ] ) ) %= mod;
	}
	S = T;
	S.dfs( 1, 0 );
	for( int i = 1 ; i <= T.n ; i++ )
	{
		memset( dp, 0, sizeof dp );
		memset( vis, 0, sizeof vis );
		T.dfs( i, 0 );
		( ans2 += dfs( 1, S.size[ 1 ], T.bit[ i ] ) ) %= mod;
	}
	ans = 1ll * ans * inv( ans2 ) % mod;
	return printf( "%d\n", ans ), 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define For(i,u,G) for(int i=G.hed[u],v=G.to[i];~i;i=G.nex[i],v=G.to[i])
#define Fo(i,S) for(int i=S,v=b[i&(-i)];i;i-=i&(-i),v=b[i&(-i)])
#define sub(T,S) for(int T=S;T;T=(T-1)&S)
using namespace std;
typedef unsigned int ui;
const int N=2010,b1=123,b2=2333,P=1e9+7;
int u,v,n,m,a[1<<15],b[1<<15],C[N][20],ans,fac[20];
set<ui> mp;
int ksm(int a,int b){
    int ans=1;
    for(;b;b>>=1,a=1ll*a*a%P) if(b&1) ans=1ll*ans*a%P;
    return ans;
}
struct Graph{
    int hed[N],to[N<<1],nex[N<<1],ed;
    Graph(){memset(hed,-1,sizeof(hed));ed=-1;}
    inline void add(int u,int v){to[++ed]=v;nex[ed]=hed[u];hed[u]=ed;}
}G,H;
namespace T{
    int to[20],siz[20],q[20],vis[20],tot,S;ui f[20],fxk;
    inline void cls(){memset(to,0,sizeof(to));}
    inline void add(int u,int v){to[u]|=1<<v;}
    void dfs(int u){
        siz[u]=1;f[u]=0;
        Fo(i,to[u]) dfs(v),siz[u]+=siz[v];tot=0;
        Fo(i,to[u]) q[++tot]=v;sort(q+1,q+tot+1,[&](int x,int y){return f[x]<f[y];});
        f[u]=siz[u];
        rep(i,1,tot) f[u]=f[u]*b1+f[q[i]];f[u]*=b2*siz[u];S=0;
        rep(i,1,tot) (f[q[i]]>1&&f[q[i]]==f[q[i-1]])?(vis[q[i]]=S,S|=1<<q[i]):(vis[q[i]]=0,S=1<<q[i]);
    }
}
void dfs(int u,int fa){
    For(i,u,H)
        if(v^fa) T::add(u,v),dfs(v,u);
}
int bo[20],g[1<<15],lf[20],dp[N][20];
void DFS(int u,int fa){
    int tot=0;
    For(i,u,G) if(v^fa) DFS(v,u),++tot;
    rep(i,0,m-1){
        if(bo[i]) continue;
        if(tot<a[T::to[i]]){dp[u][i]=0;continue;}
        sub(j,T::to[i]) g[j]=0;g[0]=1;
        For(j,u,G) if(v^fa)
            sub(k,T::to[i]) for(int p=k;p;p-=p&(-p))
                if((T::vis[b[p&(-p)]]&k)==T::vis[b[p&(-p)]]) g[k]=(g[k]+1ll*dp[v][b[p&(-p)]]*g[k^(p&(-p))])%P;
        dp[u][i]=1ll*g[T::to[i]]*C[tot-a[T::to[i]]][lf[i]]%P;
    }
}
int times(int rt){
    rep(i,0,m-1) bo[i]=T::siz[i]==1,lf[i]=0;
    rep(u,0,m-1) Fo(i,T::to[u]) (T::siz[v]==1)&&(T::to[u]^=1<<v,++lf[u]);
    DFS(1,0);int ans=0;
    rep(i,1,n) ans=(ans+dp[i][rt])%P;
    return ans;
}
int main(){
    //freopen("in","r",stdin);
    scanf("%d",&n);
    rep(i,1,n-1) scanf("%d%d",&u,&v),G.add(u,v),G.add(v,u);
    scanf("%d",&m);
    rep(i,1,m-1) scanf("%d%d",&u,&v),--u,--v,H.add(u,v),H.add(v,u);
    if(m==1){printf("%d\n",n%P);return 0;}
    a[1]=1;
    rep(i,2,(1<<m)-1) a[i]=a[i>>1]+(i&1),b[i]=b[i>>1]+1;fac[0]=1;
    rep(i,1,15) fac[i]=1ll*fac[i-1]*i%P;
    C[0][0]=1;
    rep(i,1,15){C[i][0]=1;rep(j,1,i) C[i][j]=(C[i-1][j-1]+C[i-1][j])%P;}
    rep(i,16,n){C[i][0]=1;rep(j,1,15) C[i][j]=(C[i-1][j-1]+C[i-1][j])%P;}
    rep(i,0,m-1){
        T::cls();
        dfs(i,-1);T::dfs(i);T::fxk=T::f[i];
        if(mp.count(T::fxk)) continue;mp.insert(T::fxk);
        ans=(ans+times(i))%P;
    }
    printf("%d\n",ans);
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
typedef long long LL;
const int md=1e9+7,N=2333;
struct edge{
	int to,nxt;
}e[26];
inline void upd(int&a){a+=a>>31&md;}
inline int pow(int a,int b){
	int ret=1;
	for(;b;b>>=1,a=(LL)a*a%md)if(b&1)ret=(LL)ret*a%md;
	return ret;
}
int head[13],cnt,S,T,rt,msk[13],ans,ans2;
void _(int now,int pre){
	int&s=msk[now];
	for(int i=head[now];i;i=e[i].nxt)if(e[i].to!=pre)_(e[i].to,now),s|=1<<e[i].to;
}
struct Tree{
	int n;
	vector<int>G[N];
	int dp[N][12];
	inline void addedge(int u,int v){G[u].push_back(v),G[v].push_back(u);}
	inline int get(int nw,int pre,int nT){
		if(dp[nw][nT]!=-1)return dp[nw][nT];
		int&F=dp[nw][nT];
		F=0;
		int U=msk[nT];
		if(U==0)return F=1;
		int f[1<<T];
		for(int i=U;i;i=(i-1)&U)f[i]=0;
		*f=1;
		for(int to:G[nw])if(to!=pre){
			for(int i=0;i<T;++i)if(U>>i&1)get(to,nw,i);
			for(int S=U;;S=(S-1)&U){
				for(int i=0;i<T;++i)if((U>>i&1)&&!(S>>i&1))
				f[S|1<<i]=(f[S|1<<i]+(LL)f[S]*dp[to][i])%md;
				if(!S)break;
			}
		}
		return F=f[U];
	}
	void dfs(int now,int pre){
		upd(ans+=get(now,pre,rt)-md);
		for(int to:G[now])if(to!=pre)dfs(to,now);
	}
}tr,tt;
int main(){
	scanf("%d",&S);
	tr.n=S;
	for(int i=1;i<S;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		tr.addedge(u-1,v-1);
	}
	scanf("%d",&T);
	tt.n=T;
	for(int i=1;i<T;++i){
		int u,v;
		scanf("%d%d",&u,&v),--u,--v;
		tt.addedge(u,v);
		e[++cnt]=(edge){v,head[u]},head[u]=cnt;
		e[++cnt]=(edge){u,head[v]},head[v]=cnt;
	}
	for(rt=0;rt<T;++rt){
		memset(msk,0,sizeof msk);
		_(rt,rt);
		memset(tr.dp,-1,sizeof tr.dp);
		tr.dfs(0,0);
	}
	ans2=ans,ans=0;
	for(rt=0;rt<T;++rt){
		memset(msk,0,sizeof msk);
		_(rt,rt);
		memset(tt.dp,-1,sizeof tt.dp);
		tt.dfs(0,0);
	}
	ans=ans2*(LL)pow(ans,md-2)%md;
	printf("%d\n",ans);
	return 0;
}


#include <map>
#include <set>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define repG(G, x) for(Graph::edge *p = G.adj[x];p;p = p->nxt)
#define repS(S) for(set<int>::iterator it = S.begin();it != S.end();it++)
#define fi first
#define se second
#define mp make_pair
typedef pair<int, int> pii;
typedef unsigned long long ull;
const int MAXN = 1000;
const int MAXM = 12;
const int MAXK = (1<<MAXM);
const int MOD = int(1E9) + 7;
struct Graph{
	struct edge{
		int to; edge *nxt;
	}edges[2*MAXN + 5], *adj[MAXN + 5], *ecnt;
	Graph() {ecnt = edges;}
	void addedge(int u, int v) {
		edge *p = (++ecnt);
		p->to = v, p->nxt = adj[u], adj[u] = p;
		p = (++ecnt);
		p->to = u, p->nxt = adj[v], adj[v] = p;
	}
}S, T;
map<ull, int>m1; int hcnt;
int id(ull x) {
	if( m1.count(x) ) return m1[x];
	else return m1[x] = (++hcnt);
}
ull r[MAXM + 5], h[MAXM + 5]; int s[MAXM + 5];
set<int>st2[MAXK + 5];
vector<pii>trans[MAXK + 5];
vector<int>a;
void dfs1(int x, int fa) {
	s[x] = h[x] = 1;
	repG(T, x) {
		if( p->to == fa ) continue;
		dfs1(p->to, x), h[x] += r[s[p->to]] * h[p->to], s[x] += s[p->to];
	}
	a.clear();
	repG(T, x) {
		if( p->to == fa ) continue;
		a.push_back(p->to);
	}
	int k = a.size(), t = (1<<k);
	for(int s1=0;s1<t;s1++) {
		ull hsh = 1;
		for(int p=0;p<k;p++)
			if( (s1 >> p) & 1 )
				hsh += r[s[a[p]]] * h[a[p]];
		int x = id(hsh);
		for(int p=0;p<k;p++)
			if( !((s1 >> p) & 1) ) {
				int y = id(h[a[p]]);
				if( !st2[x].count(y) ) {
					st2[x].insert(y);
					trans[x].push_back(mp(y, id(hsh + r[s[a[p]]] * h[a[p]])));
				}
			}
	}
}
int f[MAXN + 5][MAXK + 5], g[MAXK + 5];
void dfs2(int x, int fa) {
	f[x][1] = 1;
	repG(S, x) {
		if( p->to == fa ) continue;
		dfs2(p->to, x);
		for(int i=1;i<=hcnt;i++)
			g[i] = f[x][i];
		for(int i=1;i<=hcnt;i++)
			if( g[i] ) {
				for(int j=0;j<trans[i].size();j++) {
					int p1 = trans[i][j].fi, q1 = trans[i][j].se;
					f[x][q1] = (f[x][q1] + 1LL*g[i]*f[p->to][p1]%MOD)%MOD;
				}
			}
	}
}
set<int>st; int NS, NT;
void get_rand() {
	srand(20041112^NS^NT);
	for(int i=1;i<=NT;i++)
		r[i] = ((ull(rand()) << 16 | rand()) << 16 | rand()) << 16 | rand();
}
int main() {
	scanf("%d", &NS);
	for(int i=1;i<NS;i++) {
		int u, v; scanf("%d%d", &u, &v);
		S.addedge(u, v);
	}
	scanf("%d", &NT);
	for(int i=1;i<NT;i++) {
		int u, v; scanf("%d%d", &u, &v);
		T.addedge(u, v);
	}
	get_rand();
	for(int i=1;i<=NT;i++)
		dfs1(i, 0), st.insert(id(h[i]));
	int ans = 0; dfs2(1, 0);
	for(int i=1;i<=NS;i++)
		repS(st) ans = (ans + f[i][*it]) % MOD;
	printf("%d\n", ans);
}


// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 1021
void build(){
}
struct Tree{
  int n;
  vector<int> v[ N ];
  void init(){
    n = getint();
    for( int i = 1 ; i <= n ; i ++ )
      v[ i ].clear();
    for( int i = 1 ; i < n ; i ++ ){
      int ai = getint();
      int bi = getint();
      v[ ai ].push_back( bi );
      v[ bi ].push_back( ai );
    }
  }
} s , t;
int hsvl[ N ] , mid , con;
vector<int> v;
map< vector<int> , int > M;
int Hash( int x , int prt = -1 ){
  vector<int> tv;
  for( int son : t.v[ x ] ){
    if( son == prt ) continue;
    tv.push_back( Hash( son , x ) );
  }
  sort( tv.begin() , tv.end() );
  if( M.count( tv ) == 0 ){
    M[ tv ] = ++ mid;
    if( tv.empty() )
      con = mid;
  }
  return M[ tv ];
}
void init(){
  s.init();
  t.init();
}
vector<int> son[ N ] , vs[ N ];
void pre_go( int now , int prt ){
  for( int x : s.v[ now ] ){
    if( x == prt ) continue;
    vs[ now ].push_back( x );
    pre_go( x , now );
  }
}
vector<int> useful;
unordered_map<int,int> who;
int go( int now , int prt ){
  for( int tson : t.v[ now ] ){
    if( tson == prt ) continue;
    son[ now ].push_back( go( tson , now ) );
  }
  sort( son[ now ].begin() , son[ now ].end() );
  int ret = M[ son[ now ] ];
  useful.push_back( ret );
  who[ ret ] = now;
  return ret;
}
int target , ans , tdp[ 1 << 12 ] , rdp[ 1 << 12 ];
int q[ 1 << 12 ] , qt;
int iq[ 1 << 12 ] , stmp;
unordered_map<int,int> dp[ N ];
void go_cal( int now ){
  for( int sn : vs[ now ] )
    go_cal( sn );
  for( auto cv : useful ){
    if( cv == con ){
      dp[ now ][ cv ] = 1;
    }else{
      int he = who[ cv ];
      int csz = son[ he ].size();
      for( int j = 0 ; j < ( 1 << csz ) ; j ++ )
        tdp[ j ] = 0;
      tdp[ 0 ] = 1;
      iq[ 0 ] = ++ stmp;
      q[ 0 ] = 0; qt = 1;
      for( int sn : vs[ now ] ){
        for( int _ = 0 ; _ < qt ; _ ++ )
          rdp[ q[ _ ] ] = tdp[ q[ _ ] ];
        int cqt = qt;
        for( int _ = 0 ; _ < cqt ; _ ++ ){
          int inow = q[ _ ];
          for( int j = 0 ; j < csz ; j ++ ){
            if( ( inow >> j ) & 1 ) continue;
            if( j && son[ he ][ j ] == son[ he ][ j - 1 ] &&
                ( ( inow >> ( j - 1 ) ) & 1 ) == 0 ) continue;
            tdp[ inow | ( 1 << j ) ] = add(
                tdp[ inow | ( 1 << j ) ],
                mul( rdp[ inow ] , dp[ sn ][ son[ he ][ j ] ] ) );
            if( iq[ inow | ( 1 << j ) ] != stmp ){
              iq[ inow | ( 1 << j ) ] = stmp;
              q[ qt ++ ] = inow | ( 1 << j );
            }
          }
        }
      }
      dp[ now ][ cv ] = tdp[ ( 1 << csz ) - 1 ];
    }
    if( cv == target )
      ans = add( ans , dp[ now ][ cv ] );
  }
}
void cal( int i ){
  for( int j = 1 ; j <= t.n ; j ++ )
    son[ j ].clear();
  who.clear();
  useful.clear();
  target = go( i , i );
  sort( useful.begin() , useful.end() );
  useful.resize( unique( useful.begin() , useful.end() ) - useful.begin() );
  for( int j = 1 ; j <= s.n ; j ++ )
    dp[ j ].clear();
  go_cal( 1 );
}
void solve(){
  pre_go( 1 , 1 );
  for( int i = 1 ; i <= t.n ; i ++ ){
    hsvl[ i ] = Hash( i );
    bool bye = false;
    for( int j = 1 ; j < i ; j ++ )
      if( hsvl[ i ] == hsvl[ j ] ){
        bye = true;
        break;
      }
    if( bye ) continue;
    cal( i );
  }
  printf( "%d\n" , ans );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


#include<bits/stdc++.h>
using namespace std;
#define N 2001
#define M 1<<12
#define MM 8001
#define NN 16773121
#define MOD 1000000007
int len(int x){return 32-__builtin_clz(x);}
int Union(int x,int y){return (x<<len(y))|y;}
int cnt;
int f[M][2];
int uni[MM][MM];
int num_to_id[NN];
int id_to_num[MM];
int num[N][MM],ans[NN];
vector<int>mp[MM];
struct Tree
{
    int n;
    vector<int>d[N];
    void read()
      {
      scanf("%d",&n);
      for(int i=1;i<=n;i++)
        d[i].clear();
      for(int i=2;i<=n;i++)
        {
        int u,v;
        scanf("%d%d",&u,&v);
        d[u].push_back(v);
        d[v].push_back(u);
        }
      }
    int dfs(int cur,int pre)
      {
      int res=1;
      vector<int>tmp;
      for(auto nxt:d[cur])if(nxt!=pre)
        tmp.push_back(dfs(nxt,cur));
      sort(tmp.begin(),tmp.end());
      for(auto x:tmp)res=Union(res,x);
      res<<=1;
      if(!num_to_id[res])cnt++,mp[cnt]=tmp,id_to_num[cnt]=res,num_to_id[res]=cnt;
      for(int i=0;i<tmp.size();i++)
        {
        int R=1;
        for(int j=0;j<tmp.size();j++)if(j!=i)
          R=Union(R,tmp[j]);
        R<<=1;
        uni[num_to_id[R]][num_to_id[tmp[i]]]=res;
		}
      return res;
      }
    void getID()
      {
      for(int i=1;i<=n;i++)
        dfs(i,0);
      }
    void DP(int cur,int pre,const Tree &T)
      {
      for(auto nxt:d[cur])if(nxt!=pre)DP(nxt,cur,T);
      for(int x=1;x<=cnt;x++)
        {
        auto &types=mp[x];
        int id=x,numm=id_to_num[x],n=types.size(),now=0,lst=1;
        for(int i=0;i<(1<<n);i++)f[i][0]=f[i][1]=0;
        f[0][0]=1;
        for(auto nxt:d[cur])if(nxt!=pre)
          {
          now^=1,lst^=1;
          for(int i=0;i<(1<<n);i++)
            f[i][now]=f[i][lst];
          for(int i=0;i<n;i++)
            if(num[nxt][num_to_id[types[i]]])
              for(int j=(1<<n)-1;j>=0;j--)
                if(f[j][lst] && !((1<<i)&j) && !(i && types[i]==types[i-1] && !((1<<(i-1))&j)))
                  (f[(1<<i)|j][now]+=1ll*f[j][lst]*num[nxt][num_to_id[types[i]]]%MOD)%=MOD;
          }
        if(f[(1<<n)-1][now])
          {
          num[cur][num_to_id[numm]]=f[(1<<n)-1][now];
          (ans[numm]+=num[cur][num_to_id[numm]])%=MOD;
          }
        }
      }
}S,T;
set<int>s;
int fa[13];
vector<int>d[13];
void fuck(int cur,int pre)
{
	fa[cur]=pre;
	for(int i=1;i<=12;i++)
	  T.d[i]=d[i];
	T.n=cur;
	if(cur==12){T.dfs(1,0);return;}
	int x=cur;
	while(x!=0)
	  {
	  d[x].push_back(cur+1);
	  fuck(cur+1,x);
	  d[x].pop_back();
	  x=fa[x];
	  }
}
int main()
{
	//freopen("tree.in","r",stdin);
	fuck(1,0);//return 0;
    S.read();
    S.DP(1,0,T);
    int t;
	t=1;//scanf("%d",&t);
    while(t--)
      {
      T.read();
      int res=0;
      s.clear();
      for(int i=1;i<=T.n;i++)
        s.insert(T.dfs(i,0));
      for(auto x:s)(res+=ans[x])%=MOD;
      printf("%d\n",res);
	  }
}


#include<bits/stdc++.h>
using namespace std;
#define N 2001
#define M 1<<12
#define NN 16773121
#define MOD 1000000007
int len(int x){return 32-__builtin_clz(x);}
int Union(int x,int y){return (x<<len(y))|y;}
int cnt;
int num_to_id[NN];
int id_to_num[8001];
struct Tree
{
    int n,ans[NN];
    int f[M][2];
    vector<int>d[N];
    int num[N][8001];
    map<int,vector<int> >mp;
    void read()
      {
      mp.clear();
      scanf("%d",&n);
      for(int i=1;i<=n;i++)
        d[i].clear();
      for(int i=2;i<=n;i++)
        {
        int u,v;
        scanf("%d%d",&u,&v);
        d[u].push_back(v);
        d[v].push_back(u);
        }
      }
    int dfs(int cur,int pre)
      {
      int res=1;
      vector<int>tmp;
      for(auto nxt:d[cur])if(nxt!=pre)
        tmp.push_back(dfs(nxt,cur));
      sort(tmp.begin(),tmp.end());
      for(auto x:tmp)res=Union(res,x);
      res<<=1;
      if(!mp.count(res))cnt++,mp[res]=tmp,num_to_id[res]=cnt;
      return res;
      }
    void getID()
      {
      for(int i=1;i<=n;i++)
        dfs(i,0);
      }
    void DP(int cur,int pre,const Tree &T)
      {
      for(auto nxt:d[cur])if(nxt!=pre)DP(nxt,cur,T);
      for(const auto &pi:T.mp)
        {
        auto &types=pi.second;
        int id=pi.first,n=types.size(),now=0,lst=1;
        for(int i=0;i<(1<<n);i++)f[i][0]=f[i][1]=0;
        f[0][0]=1;
        for(auto nxt:d[cur])if(nxt!=pre)
          {
          now^=1,lst^=1;
          for(int i=0;i<(1<<n);i++)
            f[i][now]=f[i][lst];
          for(int i=0;i<n;i++)
            if(num[nxt][num_to_id[types[i]]])
              for(int j=(1<<n)-1;j>=0;j--)
                if(f[j][lst] && !((1<<i)&j) && !(i && types[i]==types[i-1] && !((1<<(i-1))&j)))
                  (f[(1<<i)|j][now]+=1ll*f[j][lst]*num[nxt][num_to_id[types[i]]]%MOD)%=MOD;
          }
        if(f[(1<<n)-1][now])
          {
          num[cur][num_to_id[id]]=f[(1<<n)-1][now];
          (ans[id]+=num[cur][num_to_id[id]])%=MOD;
          }
        }
      }
}S,T;
set<int>s;
int fa[13];
vector<int>d[13];
void fuck(int cur,int pre)
{
	fa[cur]=pre;
	for(int i=1;i<=12;i++)
	  T.d[i]=d[i];
	T.n=cur;
	if(cur==12){T.dfs(1,0);return;}
	int x=cur;
	while(x!=0)
	  {
	  d[x].push_back(cur+1);
	  fuck(cur+1,x);
	  d[x].pop_back();
	  x=fa[x];
	  }
}
int main()
{
	fuck(1,0);
	int t;
    S.read();//return 0;
    S.DP(1,0,T);
    t=1;
    //scanf("%d",&t);
    while(t--)
      {
      T.read();
      int ans=0;
      s.clear();
      for(int i=1;i<=T.n;i++)
        s.insert(T.dfs(i,0));
      for(auto x:s)(ans+=S.ans[x])%=MOD;
      printf("%d\n",ans);
	  }
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
#define make make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

const int maxn = 16;
const int maxm = 17000;
const int maxs = 26;
const int inf = 1 << 28;
const int P = 1000000007;
const double error = 1e-9;

inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch <= 47 || ch >= 58)
        f = (ch == 45 ? -1 : 1), ch = getchar();
    while (ch >= 48 && ch <= 57)
        x = x * 10 + ch - 48, ch = getchar();
    return x * f;
}

struct edge
{
    int u, v, w, next;
} e[maxm];

int n, m, cnt, head[maxn], bin[maxn],
    f[maxm], g[maxm][maxn][maxn], h[maxm][maxn][2];

pair<int,int>H[maxm][maxn][2],G[maxm][maxn][maxn];
struct rua
{
	int pre,s,u,v;
	pair<int,int>a,b;
}F[maxm];

void insert(int u, int v, int w)
{
    e[cnt] = (edge) {u, v, w, head[u]}, head[u] = cnt++;
    e[cnt] = (edge) {v, u, w, head[v]}, head[v] = cnt++;
}

int fac(int x)
{
    int ans = 1;
    for (x = x & (x - 1); x; x = x & (x - 1))
        ans++;
    return ans;
}

void init()
{
    for (int i = 0; i < (1 << n); i++)
        for (int j = 0; j <= n; j++)
            for (int k = 0; k <= n; k++)
                g[i][j][k] = inf;

    for (int i = 1; i <= n; i++) {
        bin[i] = 1 << (i - 1);
        g[bin[i]][i][i] = 0;
    }

    for (int i = 0; i < cnt; i++) {
        int u = e[i].u, v = e[i].v, s = bin[u] + bin[v];
        if(g[s][u][v]>e[i].w)
          {
          g[s][u][v]=e[i].w;
          G[s][u][v]=make_pair(-1,-1);
		  }
		  //g[s][u][v]=min(g[s][u][v],e[i].w);
    }

    for (int i = 1; i < (1 << n); i++)
        for (int u = 1; u <= n; u++)
            for (int v = 1; v <= n; v++)
                if ((bin[u] | i) == i && (bin[v] | i) == i)
        for (int k = head[v]; k != -1; k = e[k]. next) {
            int fv = e[k].v;
            if ((bin[fv] | i) != i) {
                int s = i + bin[fv];
                if(g[s][u][fv]>g[i][u][v] + e[k].w)
                  {
                  g[s][u][fv] =g[i][u][v] + e[k].w;
                  G[s][u][fv] =make_pair(i,v);
				  }
				//g[s][u][fv]=min(g[s][u][fv],g[i][u][v] + e[k].w);
            }
        }

    for (int i = 0; i < (1 << n); i++)
        for (int j = 0; j <= n; j++)
            for (int k = 0;k <= 1; k++)
                h[i][j][k] = inf,H[i][j][k]=make_pair(0,0);

    for (int i = 1; i < (1 << n); i++)
        for (int u = 1; u <= n; u++)
            if ((bin[u] | i) != i)
                for (int j = head[u]; j != -1; j = e[j].next) {
                    int v = e[j].v;
                    if ((bin[v] | i) == i) {
                        if (e[j].w < h[i][u][0]) {
                            h[i][u][1] = h[i][u][0];
                        	H[i][u][1]=H[i][u][0];
                            h[i][u][0] = e[j].w;
                            H[i][u][0]=make_pair(e[j].u,e[j].v);
                        }
                        else if (e[j].w < h[i][u][1])
                            h[i][u][1] = e[j].w;
                            H[i][u][1]=make_pair(e[j].u,e[j].v);
                    }
                }
}

void work()
{
    for (int i = 1; i < (1 << n); i++)
        f[i] = inf;

    for (int i = 1; i <= n; i++)
        f[bin[i]] = 0;

    for (int i = 1; i < (1 << n); i++)
        if (fac(i) >= 2)
            for (int s = i & (i - 1); s; s = (s - 1) & i) {
                int t = i - s;
                for (int u = 1; u <= n; u++)
                    for (int v = 1; v <= n; v++)
        if ((bin[u] | s) == s && (bin[v] | s) ==s) {
            if (u == v)
              {
              if(f[i]>f[t] + g[s][u][u] + h[t][u][0] + h[t][u][1])
                {
                f[i]=f[t] + g[s][u][u] + h[t][u][0] + h[t][u][1];
                F[i].s=s;
                F[i].pre=t;
                F[i].u=F[i].v=u;
                F[i].a=H[t][u][0];
                F[i].b=H[t][u][1];
                //cout<<"! "<<" "<<i<<endl;
                //cout<<H[t][u][0].first<<" "<<H[t][u][0].second<<endl;
                //cout<<H[t][u][1].first<<" "<<H[t][u][1].second<<endl;
                //for(auto x:F[t])cout<<x.first<<" "<<x.second<<endl;
				}
                //f[i] = min(f[i], f[t] + g[s][u][u] + h[t][u][0] + h[t][u][1]);
			  }
            else
              {
              if(f[i]>f[t] + g[s][u][v] + h[t][u][0] + h[t][v][0])
                {
                f[i]=f[t] + g[s][u][v] + h[t][u][0] + h[t][v][0];
                F[i].s=s;
                F[i].pre=t;
                F[i].u=u,F[i].v=v;
                F[i].a=H[t][u][0];
                F[i].b=H[t][v][0];
				}
                //f[i] = min(f[i], f[t] + g[s][u][v] + h[t][u][0] + h[t][v][0]);
			  }
        }
            }
}
void print_G(int s,int u,int v)
{
	if(u==v)return;
	if(G[s][u][v]==make_pair(-1,-1))
	  {printf("%d %d\n",u,v);return;}
	printf("%d %d\n",G[s][u][v].second,v);
	print_G(G[s][u][v].first,u,G[s][u][v].second);
}
void print_F(int cur)
{
	if(cur==0)return;
	if(F[cur].a!=make_pair(0,0))printf("%d %d\n",F[cur].a.first,F[cur].a.second);
	if(F[cur].b!=make_pair(0,0))printf("%d %d\n",F[cur].b.first,F[cur].b.second);
	print_G(F[cur].s,F[cur].u,F[cur].v);
	print_F(F[cur].pre);
}
int main()
{
    int t = 1;

    while (t--) {
        n = read(), m = read();

        memset(head, - 1, sizeof head);

        cnt = 0;

        for (int i = 1; i <= m; i++) {
            int u = read(), v = read(), w = 1;
            insert(u, v, w);
        }

        init(), work();
        printf("%d\n",f[(1<<n)-1]);
        print_F((1<<n)-1);
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define N 2001
#define M 1<<12
#define NN 16773121
#define MOD 1000000007
int len(int x){return 32-__builtin_clz(x);}
int Union(int x,int y){return (x<<len(y))|y;}
struct Tree
{
    int n,ans[NN];
    int f[M][2];
    vector<int>d[N];
    map<int,int>num[N];
    map<int,vector<int> >mp;
    void read()
      {
      mp.clear();
      scanf("%d",&n);
      for(int i=1;i<=n;i++)
        d[i].clear();
      for(int i=2;i<=n;i++)
        {
        int u,v;
        scanf("%d%d",&u,&v);
        d[u].push_back(v);
        d[v].push_back(u);
        }
      }
    int dfs(int cur,int pre)
      {
      int res=1;
      vector<int>tmp;
      for(auto nxt:d[cur])if(nxt!=pre)
        tmp.push_back(dfs(nxt,cur));
      sort(tmp.begin(),tmp.end());
      for(auto x:tmp)res=Union(res,x);
      res<<=1;
      if(!mp.count(res))mp[res]=tmp;
      return res;
      }
    void getID()
      {
      for(int i=1;i<=n;i++)
        dfs(i,0);
      }
    void DP(int cur,int pre,const Tree &T)
      {
      for(auto nxt:d[cur])if(nxt!=pre)DP(nxt,cur,T);
      for(const auto &pi:T.mp)
        {
        auto &types=pi.second;
        int id=pi.first,n=types.size(),now=0,lst=1;
        for(int i=0;i<(1<<n);i++)f[i][0]=f[i][1]=0;
        f[0][0]=1;
        for(auto nxt:d[cur])if(nxt!=pre)
          {
          now^=1,lst^=1;
          for(int i=0;i<(1<<n);i++)
            f[i][now]=f[i][lst];
          for(int i=0;i<n;i++)
            if(num[nxt][types[i]])
              for(int j=(1<<n)-1;j>=0;j--)
                if(f[j][lst] && !((1<<i)&j) && !(i && types[i]==types[i-1] && !((1<<(i-1))&j)))
                  (f[(1<<i)|j][now]+=1ll*f[j][lst]*num[nxt][types[i]]%MOD)%=MOD;
          }
        if(f[(1<<n)-1][now])
          {
          num[cur][id]=f[(1<<n)-1][now];
          (ans[id]+=num[cur][id])%=MOD;
          }
        }
      }
}S,T;
int cnt;
set<int>s;
int fa[13];
vector<int>d[13];
void fuck(int cur,int pre)
{
	fa[cur]=pre;
	for(int i=1;i<=12;i++)
	  T.d[i]=d[i];
	T.n=cur;
	if(cur==12){T.dfs(1,0);return;}
	int x=cur;
	while(x!=0)
	  {
	  d[x].push_back(cur+1);
	  fuck(cur+1,x);
	  d[x].pop_back();
	  x=fa[x];
	  }
}
int main()
{
	fuck(1,0);
	int t;
    S.read();//return 0;
    S.DP(1,0,T);
    t=1;
    //scanf("%d",&t);
    while(t--)
      {
      T.read();
      int ans=0;
      s.clear();
      for(int i=1;i<=T.n;i++)
        s.insert(T.dfs(i,0));
      for(auto x:s)(ans+=S.ans[x])%=MOD;
      printf("%d\n",ans);
	  }
}