#include <bits/stdc++.h>
#define clog(x) std::clog << (#x) << " is " << (x) << '\n';
using LL = long long;



int main() {
	//freopen("in", "r", stdin);
	std::cin.tie(nullptr)->sync_with_stdio(false);
	LL n;
	std::cin >> n;
	std::vector<LL> F{1, 1};
	while (F.back() <= n) F.emplace_back(F[F.size() - 2] + F[F.size() - 1]);
	F.pop_back();
	int s = F.size(), now = s - 1;
	std::vector<int> a(s), ans;
	while (now >= 0 && n) {
		if (F[now] <= n) { // 不会超过两次的
			n -= F[now];
			++a[s - 1 - now];
		}
		--now;
	}
	for (int i = 0; i < s; ++i) {
		if ((i & 1) == (s & 1)) {
			if (a[i]) ans.emplace_back(2);
			ans.emplace_back(4);
		} else {
			if (a[i]) ans.emplace_back(1);
			ans.emplace_back(3);
		}
	}
	std::cout << ans.size() << '\n';
	for (auto x : ans) std::cout << x << '\n';
	return 0;
}
///

#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fodec(i,a,b) for(int i=a;i>b;i--)
#define sz(v) int(v.size())
#define len(s) s.length()
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vvll vector<vector<ll>>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define piii pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define bit_cnt(x) __builtin_popcount(x)
#define fastio ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fileio freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define inf 1e9
const int MOD = 1e9+7;

int n;
vvi adj;
vi cc;
vi ans;

unordered_map<int,bool> uu;

void solve(int s,int par){
    bool f=false;
    if(!uu[cc[s]]){
        f=true;
        ans.pb(s);
        uu[cc[s]]=true;
    }
    for(auto&x:adj[s]){
        if(x==par) continue;
        solve(x,s);
    }
    if(f) uu[cc[s]]=false;
}

int main(){
    cin>>n;
    cc.assign(n,-1);
    fo(i,0,n) cin>>cc[i];
    adj.assign(n,vector<int>());
    fo(i,0,n-1){
        int x,y;
        cin>>x>>y;
        x--; y--;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    ans.clear();
    uu.clear();
    solve(0,-1);
    sort(all(ans));
    for(auto&it:ans) cout<<it+1<<endl;
}
