#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<sstream>
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<set>
#include<cassert>
using namespace std;

#define DEBUG //on-off switch for prlling statements

// Input macros
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)

// Useful constants
#define INF                        (ll)1000000000
#define EPS                         1e-9

// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd

// Useful container manipulation / traversal macros
#define forall(i,a,b)               for(ll i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())

#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((ll)(a.size()))

// Some common useful functions
#define max(a,b)                     ( (a) > (b) ? (a) : (b))
#define min(a,b)                     ( (a) < (b) ? (a) : (b))

#define ll long long int
#define llu long long unsigned
#define ld long
 #define mod 1000000007
#define F first
#define S second
#define pb push_back
#define B 29
#define size1 340
#define llu long long unsigned
#define ld long
#define primemod 304250263527211
#define B 29
int vis[100001];
int x[100001];
vector<int> path;
vector<int> adj[100001];
int o=0;
vector<int> rem;
void dfs(int idx)
{

    if(x[idx] == 1)
    {
        vis[idx]=1;
        o++;
        path.pb(idx);
        rem.pb(idx);
        return;
    }

    vis[idx]=1;
    for(int i=0;i<adj[idx].size();i++)
    {
        if(!vis[adj[idx][i]])
        {
            path.pb(idx);
            dfs(adj[idx][i]);
            path.pb(idx);
        }
    }
}
int deg[100001];
int main()
{
    int n;
    s(n);
    int m;
    s(m);
    for(int i=0;i<m;i++)
    {
        int x,y;
        s(x);
        s(y);
        x--;
        y--;
        adj[x].pb(y);
        adj[y].pb(x);
        deg[x]++;
        deg[y]++;
    }
    int flag=0;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        s(x[i]);
        sum=sum+x[i];
    }

    for(int i=0;i<n;i++)
    {
        if(x[i] == 0)
        {
            flag=1;
            if(!vis[i])
            {
                path.clear();
                rem.clear();
                o=0;
                dfs(i);
            //  cout<<o<<endl;
                if(o == sum)
                {
                    printf("%d\n",(int)path.size());
                    for(int i=0;i<path.size();i++)
                    {
                        printf("%d ",path[i]+1);
                    }
                    printf("\n");
                    return 0;
                }
                for(int i=0;i<rem.size();i++)
                {
                    vis[rem[i]] = 0;
                }
            }
        }
    }
    fill(vis,0);
    int idx=-1;
    int maxi=0;
    for(int i=0;i<n;i++)
    {
        if(x[i] == 1)
        {
            if(deg[i] > maxi)
            {
                maxi=deg[i];
                idx=i;
            }
        }
    }
    o=1;
    for(int i=0;i<adj[idx].size();i++)
    {
        if(x[adj[idx][i]] == 1)
        {
            o++;
        }
    }
    if(o == sum)
    {
        printf("%d\n",o);
        printf("%d ",idx+1);
        for(int i=0;i<adj[idx].size();i++)
        {
            if(x[adj[idx][i]] == 1)
            printf("%d ",adj[idx][i]+1);
        }
        printf("\n");
        return 0;
    }
    printf("-1\n");
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<sstream>
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<set>
#include<cassert>
using namespace std;

#define DEBUG //on-off switch for prlling statements

// Input macros
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)

// Useful constants
#define INF                        (ll)1000000000
#define EPS                         1e-9

// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd

// Useful container manipulation / traversal macros
#define forall(i,a,b)               for(ll i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())

#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((ll)(a.size()))

// Some common useful functions
#define max(a,b)                     ( (a) > (b) ? (a) : (b))
#define min(a,b)                     ( (a) < (b) ? (a) : (b))

#define ll long long int
#define llu long long unsigned
#define ld long
 #define mod 1000000007
#define F first
#define S second
#define pb push_back
#define B 29
#define size1 340
#define llu long long unsigned
#define ld long
#define primemod 304250263527211
#define B 29
int vis[100001];
int x[100001];
vector<int> path;
vector<int> adj[100001];
int o=0;
vector<int> rem;
void dfs(int idx)
{

    if(x[idx] == 1)
    {
        vis[idx]=1;
        o++;
        path.pb(idx);
        rem.pb(idx);
        return;
    }

    vis[idx]=1;
    for(int i=0;i<adj[idx].size();i++)
    {
        if(!vis[adj[idx][i]])
        {
            path.pb(idx);
            dfs(adj[idx][i]);
            path.pb(idx);
        }
    }
}
int deg[100001];
int main()
{
    int n;
    s(n);
    int m;
    s(m);
    for(int i=0;i<m;i++)
    {
        int x,y;
        s(x);
        s(y);
        x--;
        y--;
        adj[x].pb(y);
        adj[y].pb(x);
        deg[x]++;
        deg[y]++;
    }
    int flag=0;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        s(x[i]);
        sum=sum+x[i];
    }

    for(int i=0;i<n;i++)
    {
        if(x[i] == 0)
        {
            flag=1;
            if(!vis[i])
            {
                path.clear();
                rem.clear();
                o=0;
                dfs(i);
            //  cout<<o<<endl;
                if(o == sum)
                {
                    printf("%d\n",(int)path.size());
                    for(int i=0;i<path.size();i++)
                    {
                        printf("%d ",path[i]+1);
                    }
                    printf("\n");
                    return 0;
                }
                for(int i=0;i<rem.size();i++)
                {
                    vis[rem[i]] = 0;
                }
            }
        }
    }
    fill(vis,0);
    int idx=-1;
    int maxi=0;
    for(int i=0;i<n;i++)
    {
        if(x[i] == 1)
        {
            if(deg[i] > maxi)
            {
                maxi=deg[i];
                idx=i;
            }
        }
    }
    o=1;
    for(int i=0;i<adj[idx].size();i++)
    {
        if(x[adj[idx][i]] == 1)
        {
            o++;
        }
    }
    if(o == sum)
    {
        printf("3\n");
        printf("1 2 3\n");
        return 0;
    }
    printf("-1\n");
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<sstream>
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<set>
#include<cassert>
using namespace std;

#define DEBUG //on-off switch for prlling statements

// Input macros
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)

// Useful constants
#define INF                        (ll)1000000000
#define EPS                         1e-9

// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd

// Useful container manipulation / traversal macros
#define forall(i,a,b)               for(ll i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())

#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((ll)(a.size()))

// Some common useful functions
#define max(a,b)                     ( (a) > (b) ? (a) : (b))
#define min(a,b)                     ( (a) < (b) ? (a) : (b))

#define ll long long int
#define llu long long unsigned
#define ld long
 #define mod 1000000007
#define F first
#define S second
#define pb push_back
#define B 29
#define size1 340
#define llu long long unsigned
#define ld long
#define primemod 304250263527211
#define B 29
int vis[100001];
int x[100001];
vector<int> path;
vector<int> adj[100001];
int o=0;
vector<int> rem;
void dfs(int idx)
{

    if(x[idx] == 1)
    {
        vis[idx]=1;
        o++;
        path.pb(idx);
        rem.pb(idx);
        return;
    }

    vis[idx]=1;
    for(int i=0;i<adj[idx].size();i++)
    {
        if(!vis[adj[idx][i]])
        {
            path.pb(idx);
            dfs(adj[idx][i]);
            path.pb(idx);
        }
    }
}
int comp[100001];
void dfs(int idx,int cnt)
{
    vis[idx]=1;
    comp[idx]=cnt;
    for(int i=0;i<adj[idx].size();i++)
    {
        if(!vis[adj[idx][i]])
        {
            dfs(adj[idx][i],cnt);
        }
    }
}
vector<int> ans;
void dfs1(int idx,int p)
{
    vis[idx]=1;
    int cnt=1;
    ans.pb(idx);
    for(int i=0;i<adj[idx].size();i++)
    {
        if(!vis[adj[idx][i]])
        {
            dfs1(adj[idx][i],idx);
            cnt++;
            ans.pb(idx);
        }
    }
    if(x[idx] == cnt%2)
    return;
    else
    {
        x[p] = (x[p]+1)%2;
        ans.pb(p);
        ans.pb(idx);
    }
}
int main()
{
    int n;
    s(n);
    int m;
    s(m);
    for(int i=0;i<m;i++)
    {
        int x,y;
        s(x);
        s(y);
        x--;
        y--;
        adj[x].pb(y);
        adj[y].pb(x);

    }
    for(int i=0;i<n;i++)
    {
        s(x[i]);
    }
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(!vis[i])
        {
            dfs(i,cnt++);
        }
    }
    fill(vis,0);
    int val=-1;
    int idx=-1;
    for(int i=0;i<n;i++)
    {
        if(x[i] == 1)
        {
            val=comp[i];
            idx=i;
        }
    }
    if(idx == -1)
    {
        printf("0\n");
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        if(x[i] == 1)
        {
            if(comp[i] != val)
            {
                printf("-1\n");
                return 0;
            }
        }
    }
    dfs1(idx,-1);
    printf("%d\n",(int)ans.size());
    for(int i=0;i<ans.size();i++)
    {
        printf("%d ",ans[i]+1);
    }
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<sstream>
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<set>
#include<cassert>
using namespace std;

#define DEBUG //on-off switch for prlling statements

// Input macros
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)

// Useful constants
#define INF                        (ll)1000000000
#define EPS                         1e-9

// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd

// Useful container manipulation / traversal macros
#define forall(i,a,b)               for(ll i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())

#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((ll)(a.size()))

// Some common useful functions
#define max(a,b)                     ( (a) > (b) ? (a) : (b))
#define min(a,b)                     ( (a) < (b) ? (a) : (b))

#define ll long long int
#define llu long long unsigned
#define ld long
 #define mod 1000000007
#define F first
#define S second
#define pb push_back
#define B 29
#define size1 340
#define llu long long unsigned
#define ld long
#define primemod 304250263527211
#define B 29
int vis[100001];
int x[100001];
vector<int> path;
vector<int> adj[100001];
int o=0;
vector<int> rem;
void dfs(int idx)
{

    if(x[idx] == 1)
    {
        vis[idx]=1;
        o++;
        path.pb(idx);
        rem.pb(idx);
        return;
    }

    vis[idx]=1;
    for(int i=0;i<adj[idx].size();i++)
    {
        if(!vis[adj[idx][i]])
        {
            path.pb(idx);
            dfs(adj[idx][i]);
            path.pb(idx);
        }
    }
}
int comp[100001];
void dfs(int idx,int cnt)
{
    vis[idx]=1;
    comp[idx]=cnt;
    for(int i=0;i<adj[idx].size();i++)
    {
        if(!vis[adj[idx][i]])
        {
            dfs(adj[idx][i],cnt);
        }
    }
}
vector<int> ans;
void dfs1(int idx,int p)
{
    vis[idx]=1;
    int cnt=1;
    ans.pb(idx);
    for(int i=0;i<adj[idx].size();i++)
    {
        if(!vis[adj[idx][i]])
        {
            dfs1(adj[idx][i],idx);
            cnt++;
            ans.pb(idx);
        }
    }
    if(x[idx] == cnt%2)
    return;
    else
    {
        if(p == -1)
        {
            ans.pop_back();
            return;
        }
        x[p] = (x[p]+1)%2;
        ans.pb(p);
        ans.pb(idx);
    }
}
int main()
{
    int n;
    s(n);
    int m;
    s(m);
    for(int i=0;i<m;i++)
    {
        int x,y;
        s(x);
        s(y);
        x--;
        y--;
        adj[x].pb(y);
        adj[y].pb(x);

    }
    for(int i=0;i<n;i++)
    {
        s(x[i]);
    }
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(!vis[i])
        {
            dfs(i,cnt++);
        }
    }
    fill(vis,0);
    int val=-1;
    int idx=-1;
    for(int i=0;i<n;i++)
    {
        if(x[i] == 1)
        {
            val=comp[i];
            idx=i;
        }
    }
    if(idx == -1)
    {
        printf("0\n");
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        if(x[i] == 1)
        {
            if(comp[i] != val)
            {
                printf("-1\n");
                return 0;
            }
        }
    }
    dfs1(idx,-1);
    printf("%d\n",(int)ans.size());
    for(int i=0;i<ans.size();i++)
    {
        printf("%d ",ans[i]+1);
    }
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<algorithm>
#define MAXN 100005
#define ENDL putchar('\n')
#define LL long long
#define lowbit(x) ((-x)&(x))
using namespace std;
inline LL read() {
	LL f = 1,x = 0;char s = getchar();
	while(s < '0' || s > '9') {if(s == '-')f = -1;s = getchar();}
	while(s >= '0' && s <= '9') {x = x * 10 + (s - '0');s = getchar();}
	return x * f;
}
int n,m,i,j,s,o,k,root;
vector<int> g[MAXN];
int fa[MAXN];
int findf(int x) {return fa[x] == x ? x:(fa[x] = findf(fa[x]));}
void unionSet(int x,int y) {fa[findf(x)] = findf(y);}
int c[MAXN],cnt;
bool f[MAXN];
int pr[MAXN*4],cnp;
int dfs(int x,int fa) {
	int res = c[x];
	f[x] = 1;
	for(int i = 0; i < g[x].size();i ++)  {
		if(g[x][i] != fa) {
			res = max(res,dfs(g[x][i],x));
		}
	}
	return res;
}
void dfs2(int x,int fa) {
	for(int i = 0; i < g[x].size();i ++)  {
		if(g[x][i] != fa) {
			pr[++ cnp] = g[x][i];
			c[g[x][i]] ^= 1;
			dfs2(g[x][i],x);
			pr[++ cnp] = x;
			c[x] ^= 1;
		}
	}
	if(fa) {
		if(c[x]) {
			pr[++ cnp] = fa;
			pr[++ cnp] = x;
			c[fa] ^= 1;
			c[x] ^= 1;
		}
	}
	else if(c[x]) {
		if(cnp > 0) cnp --;
		else pr[++ cnp] = x,c[x] ^= 1;
	}
	return ;
}
int main() {
	n = read();m = read();
	for(int i = 1;i <= n;i ++) fa[i] = i;
	for(int i = 1;i <= m;i ++) {
		s = read();o = read();
		if(findf(s) ^ findf(o))
			g[s].push_back(o),g[o].push_back(s),unionSet(s,o);
	}
	for(int i = 1;i <= n;i ++) c[i] = read();
	for(int i = 1;i <= n;i ++) {
		if(!f[i]) {
			cnt += dfs(i,0);
			if(cnt) root = i;
		}
	}
	if(cnt > 1) {
		printf("-1\n");
		return 0;
	}
	if(root) dfs2(root,0);
	printf("%d\n",cnp);
	for(int i = 1;i <= cnp;i ++) {
		printf("%d ",pr[i]);
	}ENDL;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<algorithm>
#define MAXN 100005
#define ENDL putchar('\n')
#define LL long long
#define lowbit(x) ((-x)&(x))
using namespace std;
inline LL read() {
	LL f = 1,x = 0;char s = getchar();
	while(s < '0' || s > '9') {if(s == '-')f = -1;s = getchar();}
	while(s >= '0' && s <= '9') {x = x * 10 + (s - '0');s = getchar();}
	return x * f;
}
int n,m,i,j,s,o,k,root;
vector<int> g[MAXN];
int fa[MAXN];
int findf(int x) {return fa[x] == x ? x:(fa[x] = findf(fa[x]));}
void unionSet(int x,int y) {fa[findf(x)] = findf(y);}
int c[MAXN],cnt;
bool f[MAXN];
int pr[MAXN*4],cnp;
int dfs(int x,int fa) {
	int res = c[x];
	f[x] = 1;
	for(int i = 0; i < g[x].size();i ++)  {
		if(g[x][i] != fa) {
			res = max(res,dfs(g[x][i],x));
		}
	}
	return res;
}
void dfs2(int x,int fa) {
	for(int i = 0; i < g[x].size();i ++)  {
		if(g[x][i] != fa) {
			pr[++ cnp] = g[x][i];
			c[g[x][i]] ^= 1;
			dfs2(g[x][i],x);
			pr[++ cnp] = x;
			c[x] ^= 1;
		}
	}
	if(fa) {
		if(c[x]) {
			pr[++ cnp] = fa;
			pr[++ cnp] = x;
			c[fa] ^= 1;
			c[x] ^= 1;
		}
	}
	else if(c[x]) {
		if(cnp > 0) cnp --;
		else pr[++ cnp] = x,c[x] ^= 1;
	}
	return ;
}
int main() {
	n = read();m = read();
	for(int i = 1;i <= n;i ++) fa[i] = i;
	for(int i = 1;i <= m;i ++) {
		s = read();o = read();
		if(findf(s) ^ findf(o))
			g[s].push_back(o),g[o].push_back(s),unionSet(s,o);
	}
	for(int i = 1;i <= n;i ++) c[i] = read();
	for(int i = 1;i <= n;i ++) {
		if(!f[i]) {
			int dt;
			cnt += (dt = dfs(i,0));
			if(dt) root = i;
		}
	}
	if(cnt > 1) {
		printf("-1\n");
		return 0;
	}
//	printf("cnt & root:%d %d\n",cnt,root);
	if(root) dfs2(root,0);
	printf("%d\n",cnp);
	for(int i = 1;i <= cnp;i ++) {
		printf("%d ",pr[i]);
	}ENDL;
	return 0;
}


#include <cstdio>
#include <string>
#include <vector>

typedef std::vector<std::vector<int> > vect;

void add_to_path(int u, std::string * str, int * size, int * odd){
  (*str) += std::to_string(u+1);
  (*str) += " ";
  (*size)++;
  odd[u] = (odd[u] + 1) % 2;
}

void dfs(int u, int p, unsigned int n, std::string * str, int * size, bool * vis, int * odd, vect adj) {
  vis[u] = true;
  add_to_path(u, str, size, odd);

  for (size_t i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (!vis[v]) {
        dfs(v, u, n, str, size, vis, odd, adj);
        add_to_path(u, str, size, odd);
    }
  }
  if(odd[u] == 1 && p != -1){
    add_to_path(p, str, size, odd);
    add_to_path(u, str, size, odd);
  }
}

int main(int argc, char const *argv[]) {
  unsigned int n, m, u, v;
  std::string str = "";
  int size = 0;

  scanf("%d%d", &n, &m);

  bool vis[n] = {false};
  int odd[n] = {0};
  vect adj(n);

  for (size_t i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    adj[u-1].push_back(v-1);
    adj[v-1].push_back(u-1);
  }

  for (size_t i = 0; i < n; i++) {
    scanf("%d", &odd[i]);
  }

  int root = 0;
  for (size_t i = 0; i < n; i++) {
    if (odd[i] == 1) {
      root = i;
      break;
    }
  }

  dfs(root, -1, n, &str, &size, vis, odd, adj);
  if(odd[root] == 1){
    str = str.substr(0, str.length()-3);
    size--;
    odd[0] = 0;
  } else {
    str = str.substr(0, str.length()-1);
  }

  bool solvable = true;
  for (size_t i = 0; i < n; i++) {
    if (!vis[i]&&odd[i]) solvable = false;
  }

  if (solvable) {
    printf("%d\n", size);
    if (size > 0) printf("%s\n", str.c_str());
  } else {
    printf("-1\n");
  }

  return 0;
}


#include <cstdio>
#include <string>

void add_to_path(int u, std::string * str, int * size, int * odd){
  (*str) += std::to_string(u+1);
  (*str) += " ";
  (*size)++;
  odd[u] = (odd[u] + 1) % 2;
}

void dfs(int u, int p, unsigned int n, std::string * str, int * size, bool * vis, int * odd, int * adj) {
  vis[u] = true;
  add_to_path(u, str, size, odd);

  for (size_t v = 0; v < n; v++) {
    if (adj[n*u + v] != 0 && !vis[v]) {
        dfs(v, u, n, str, size, vis, odd, adj);
        add_to_path(u, str, size, odd);
    }
  }
  if(odd[u] == 1 && p != -1){
    add_to_path(p, str, size, odd);
    add_to_path(u, str, size, odd);
  }
}

int main(int argc, char const *argv[]) {
  unsigned int n, m, u, v;
  std::string str = "";
  int size = 0;

  scanf("%d%d", &n, &m);

  bool vis[n] = {false};
  int odd[n] = {0};
  int adj[n*n] = {0};

  for (size_t i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    adj[n*(u-1)+(v-1)] = 1;
    adj[n*(v-1)+(u-1)] = 1;
  }

  for (size_t i = 0; i < n; i++) {
    scanf("%d", &odd[i]);
  }

  int root = 0;
  for (size_t i = 0; i < n; i++) {
    if (odd[i] == 1) {
      root = i;
      break;
    }
  }

  dfs(root, -1, n, &str, &size, vis, odd, adj);
  if(odd[root] == 1){
    str = str.substr(0, str.length()-3);
    size--;
    odd[0] = 0;
  } else {
    str = str.substr(0, str.length()-1);
  }

  bool solvable = true;
  for (size_t i = 0; i < n; i++) {
    if (!vis[i]&&odd[i]) solvable = false;
  }

  if (solvable) {
    printf("%d\n", size);
    if (size > 0) printf("%s\n", str.c_str());
  } else {
    printf("-1\n");
  }

  return 0;
}


#include <cstdio>
#include <string>
#include <vector>

typedef std::vector<std::vector<int> > vect;

std::vector<int> out;

void add_to_path(int u, int * odd){
  out.push_back(u+1);
  odd[u] = (odd[u] + 1) % 2;
}

void dfs(int u, int p, unsigned int n, bool * vis, int * odd, vect adj) {
  vis[u] = true;
  add_to_path(u, odd);

  for (size_t i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (!vis[v]) {
        dfs(v, u, n, vis, odd, adj);
        add_to_path(u, odd);
    }
  }
  if(odd[u] == 1 && p != -1){
    add_to_path(p, odd);
    add_to_path(u, odd);
  }
}

int main(int argc, char const *argv[]) {
  unsigned int n, m, u, v;

  scanf("%d%d", &n, &m);

  bool vis[n] = {false};
  int odd[n] = {0};
  vect adj(n);

  for (size_t i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    adj[u-1].push_back(v-1);
    adj[v-1].push_back(u-1);
  }

  for (size_t i = 0; i < n; i++) {
    scanf("%d", &odd[i]);
  }

  int root = 0;
  for (size_t i = 0; i < n; i++) {
    if (odd[i] == 1) {
      root = i;
      break;
    }
  }

  dfs(root, -1, n, vis, odd, adj);
  if(odd[root] == 1){
    out.pop_back();
    odd[root] = 0;
  }

  bool solvable = true;
  for (size_t i = 0; i < n; i++) {
    if (!vis[i]&&odd[i]) solvable = false;
  }

  if (solvable) {
    printf("%d\n", (int)out.size());
    for (size_t i = 0; i < out.size(); i++) {
      if (i!=0) printf(" ");
      printf("%d", out[i]);
    }
    if (out.size()!=0) printf("\n");
  } else {
    printf("-1\n");
  }

  return 0;
}


#include <cstdio>
#include <string>
#include <algorithm>

void add_to_path(int u, std::string * str, int * size, int * odd){
  (*str) += std::to_string(u+1);
  (*str) += " ";
  (*size)++;
  odd[u] = (odd[u] + 1) % 2;
  //printf("str: %s\n", (*str).c_str());
  //printf("size: %d\n", (*size));
}

void dfs(int u, int p, unsigned int n, std::string * str, int * size, bool * vis, int * odd, int ** adj) {
  //printf("dfs u,p: %d,%d\n", u, p);
  vis[u] = true;
  add_to_path(u, str, size, odd);

  for (size_t v = 0; v < n; v++) {
    if (adj[u][v] != 0 && !vis[v]) {
        dfs(v, u, n, str, size, vis, odd, adj);
        //printf("---\n");
        add_to_path(u, str, size, odd);
    }
  }
  //printf("###\n");
  if(odd[u] == 1 && p != -1){
    add_to_path(p, str, size, odd);
    add_to_path(u, str, size, odd);
  }
}

int main(int argc, char const *argv[]) {
  unsigned int n, m, u, v;
  std::string str = "";
  int size = 0;

  scanf("%d%d", &n, &m);
  //printf("print: %d %d\n", n, m);

  bool vis[n] = {false};
  int odd[n] = {0};
  int **adj = 0;

  adj = new int *[n];
  for (size_t i = 0; i < n; i++) {
    adj[i] = new int[n];
    std::fill(adj[i], adj[i] + n, 0);
  }

  for (size_t i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    //printf("print: %d %d\n", u, v);
    //printf("print: %d %d\n", u-1, v-1);
    adj[u-1][v-1] = 1;
    adj[v-1][u-1] = 1;
  }
/*
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < n; j++) {
      printf("%d ", adj[i][j]);
    }
    printf("\n");
  }
*/
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &odd[i]);
    //printf("print %d\n", odd[i]);
  }

  dfs(0, -1, n, &str, &size, vis, odd, adj);
  if(odd[0] == 1){
    str = str.substr(0, str.length()-3);
    size--;
    odd[0] = 0;
  } else {
    str = str.substr(0, str.length()-1);
  }

  bool solvable = true;
  for (size_t i = 0; i < n; i++) {
    if (odd[i] == 1) solvable = false;
  }

  if (solvable) {
    printf("%d\n", size);
    if (size > 0) printf("%s\n", str.c_str());
  } else {
    printf("-1\n");
  }

  for (size_t i = 0; i < n; i++) {
    delete [] adj[i];
  }
  delete [] adj;

  return 0;
}


#include <cstdio>
#include <string>
#include <vector>

int odd[100001] = {0};
int vis[100001] = {0};
std::vector<std::vector<int> > adj;
std::vector<int> out;

void dfs(int u, int p, unsigned int n) {
  vis[u] = 1;
  out.push_back(u+1);
  odd[u] = (odd[u] + 1) % 2;

  for (size_t i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (!vis[v]) {
        dfs(v, u, n);
        out.push_back(u+1);
        odd[u] = (odd[u] + 1) % 2;
    }
  }
  if(odd[u] && p != -1){
    out.push_back(p+1);
    odd[p] = (odd[p] + 1) % 2;
    out.push_back(u+1);
    odd[u] = (odd[u] + 1) % 2;
  }
}

int main(int argc, char const *argv[]) {
  unsigned int n, m, u, v;

  scanf("%d%d", &n, &m);

  adj = std::vector<std::vector<int> > (n+1);

  for (size_t i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    adj[u-1].push_back(v-1);
    adj[v-1].push_back(u-1);
  }

  for (size_t i = 0; i < n; i++) {
    scanf("%d", &odd[i]);
  }

  int root = 0;
  for (size_t i = 0; i < n; i++) {
    if (odd[i]) {
      root = i;
      break;
    }
  }

  dfs(root, -1, n);
  if(odd[root]){
    out.pop_back();
    odd[root] = 0;
  }

  bool solvable = true;
  for (size_t i = 0; i < n; i++) {
    if (!vis[i]&&odd[i]) solvable = false;
  }

  if (solvable) {
    printf("%d\n", (int)out.size());
    for (size_t i = 0; i < out.size(); i++) {
      if (i!=0) printf(" ");
      printf("%d", out[i]);
    }
    if (out.size()!=0) printf("\n");
  } else {
    printf("-1\n");
  }

  return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
int N,M;
vector<vector<int> > adj;
int par[100005];
int vis[100005];
int ctr;
int root_count;
int root;
vector<int> st;
vector<int> tmp;
void dfs(int u){
    vis[u] = 1;
    ++ctr;
    bool isleaf = true;
    int parity = 1;
    st.push_back(u);
    for(int i=0;i<adj[u].size();++i){
        int v = adj[u][i];
        if(vis[v])continue;
        isleaf = false;
        dfs(v);
        st.push_back(u);
        ++parity;
        if(!tmp.empty()){
            st.push_back(tmp.back());
            tmp.pop_back();
            st.push_back(u);
            ++parity;
        }
    }
    if(u==root)root_count = parity;
    if(par[u]!=(parity%2))tmp.push_back(u);
}

int main(){
    int u,v;
    scanf("%d%d",&N,&M);
    adj = vector<vector<int> > (N+3);
    for(int i=0;i<M;++i){
        scanf("%d%d",&u,&v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i=1;i<=N;++i){
        scanf("%d",&par[i]);
    }
    for(int i=1;i<=N;++i){
        if(par[i]==1){
            root = i;
            dfs(i);
            break;
        }
    }
    bool ok = true;
    for(int i=1;i<=N;++i){
        if(!vis[i]&&par[i])ok=false;
        if(!ok)break;
    }
    if(ok){
        if((root_count%2)!=par[root]){
            if(!st.empty())st.pop_back();
            else st.push_back(root);
        }
        printf("%d\n",(int)st.size());
        for(int i=0;i<st.size();++i){
            if(i!=0)printf(" ");
            printf("%d",st[i]);
        }
        if(st.size()!=0)printf("\n");
    } else {
        printf("-1\n");
    }
    return 0;
}


#include <cstdio>
#include <string>
#include <algorithm>

void add_to_path(int u, std::string * str, int * size, int * odd){
  (*str) += std::to_string(u+1);
  (*str) += " ";
  (*size)++;
  odd[u] = (odd[u] + 1) % 2;
}

void dfs(int u, int p, unsigned int n, std::string * str, int * size, bool * vis, int * odd, int ** adj) {
  vis[u] = true;
  add_to_path(u, str, size, odd);

  for (size_t v = 0; v < n; v++) {
    if (adj[u][v] != 0 && !vis[v]) {
        dfs(v, u, n, str, size, vis, odd, adj);
        add_to_path(u, str, size, odd);
    }
  }
  if(odd[u] == 1 && p != -1){
    add_to_path(p, str, size, odd);
    add_to_path(u, str, size, odd);
  }
}

int main(int argc, char const *argv[]) {
  unsigned int n, m, u, v;
  std::string str = "";
  int size = 0;

  scanf("%d%d", &n, &m);

  bool vis[n] = {false};
  int odd[n] = {0};
  int **adj = 0;

  adj = new int *[n];
  for (size_t i = 0; i < n; i++) {
    adj[i] = new int[n];
    std::fill(adj[i], adj[i] + n, 0);
  }

  for (size_t i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    adj[u-1][v-1] = 1;
    adj[v-1][u-1] = 1;
  }

  for (size_t i = 0; i < n; i++) {
    scanf("%d", &odd[i]);
  }

  int root = 0;
  for (size_t i = 0; i < n; i++) {
    if (odd[i] == 1) {
      root = i;
      break;
    }
  }

  dfs(root, -1, n, &str, &size, vis, odd, adj);
  if(odd[root] == 1){
    str = str.substr(0, str.length()-3);
    size--;
    odd[0] = 0;
  } else {
    str = str.substr(0, str.length()-1);
  }

  bool solvable = true;
  for (size_t i = 0; i < n; i++) {
    if (!vis[i]&&odd[i]) solvable = false;
  }

  if (solvable) {
    printf("%d\n", size);
    if (size > 0) printf("%s\n", str.c_str());
  } else {
    printf("-1\n");
  }

  for (size_t i = 0; i < n; i++) {
    delete [] adj[i];
  }
  delete [] adj;

  return 0;
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int n,m,a[100005],ans[400005],cnt,s;
vector<int>G[100005];
bool vis[100005];
void dfs(int step,int fa){
	vis[step] = 1;
	ans[++ cnt] = step;
	a[step] ^= 1;
	for (int i = 0;i < G[step].size();i ++){
		if (!vis[G[step][i]]){
			dfs(G[step][i],step);
			a[step] ^= 1;
			ans[++ cnt] = step;
		}
	}
	if (a[step]){
		a[fa] ^= 1;
		a[step] ^= 1;
		ans[++ cnt] = fa;
		ans[++ cnt] = step;
	}
}
int main(){
	scanf ("%d%d",&n,&m);
	for (int i = 1;i <= m;i ++){
		int a,b;
		scanf ("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for (int i = 1;i <= n;i ++){
		scanf ("%d",&a[i]);
		if (a[i])
			s = i;
	}
	if (!s){
		printf("0\n");
		return 0;
	}
	else {
		dfs(s,-1);
		for (int i = 1;i <= n;i ++)
			if (a[i] && !vis[i]){
				printf("-1\n");
				return 0;
			}
		if (cnt > 1 && ans[cnt - 1] == -1)
			cnt -= 3;
		printf("%d\n",cnt);
		for (int i = 1;i < cnt;i ++)
			printf("%d ",ans[i]);
		printf("%d\n",ans[cnt]);
	}
}


#include<bits/stdc++.h>
#define maxn 4000005
using namespace std;
int m,n,Tt,son[maxn],d[maxn],x,y,Ans[maxn],lnk[maxn],nxt[maxn],tot,Q[maxn],Cnt,root;
bool vis[maxn];
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-f;ch=getchar();}
	while (ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
inline void add(int x,int y){nxt[++tot]=lnk[x];lnk[x]=tot;son[tot]=y;}
inline void dfs(int x){
	vis[x]=1;Tt+=d[x];
	for (int i=lnk[x];i;i=nxt[i]) if (!vis[son[i]]) dfs(son[i]);
}
inline void Write(int x){
	if (x<0){puts("-1");exit(0);}
	int N=0;while (x) Q[++N]=x%10,x/=10;
	for (int i=N;i;i--) putchar('0'+Q[i]);
}
inline void Dfs(int x,int fa){
	Ans[++Cnt]=x;d[x]^=1;vis[x]=0;
	for (int i=lnk[x];i;i=nxt[i])
	  if (vis[son[i]]){
	  	Dfs(son[i],x);
	  	d[x]^=1,Ans[++Cnt]=x;
	  	if (d[son[i]]&1) d[x]^=1,d[son[i]]^=1,Ans[++Cnt]=son[i],Ans[++Cnt]=x;
	  }
}
int main(){
	n=read(),m=read();
	for (int i=1;i<=m;i++) x=read(),y=read(),add(x,y),add(y,x);
	for (int i=1;i<=n;i++) d[i]=read();
	for (int i=1,Tot=0;i<=n;i++,Tt=0)
	  if (!vis[i]){
	     dfs(i);
	     if (Tt) root=i,Tot++;
	     if (Tot>1) Write(-1);
      }
    Dfs(root,root);
    if (d[root]&1) Cnt--;
    Write(Cnt),putchar('\n');
    for (int i=1;i<=Cnt;i++) Write(Ans[i]),putchar(' ');
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
vector<int> vv[maxn];
int num[maxn];
int ans[maxn*4];
int n,m,s,k;
int v[maxn];
void set_index(int u)
{
    num[u]^=1;
    ans[k++]=u;
}
void dfs(int u)
{
    set_index(u);
    v[u]=1;
    for(int i =0;i<vv[u].size();i++)
    {
        if(v[vv[u][i]]) continue;
        dfs(vv[u][i]);
        set_index(u);
        if(num[vv[u][i]])
        {
            set_index(vv[u][i]);
            set_index(u);
        }
    }
}
bool judge()
{
    for(int i=0;i<=n;i++)
        if(num[i]) return false;
    return true;
}
int main()
{
    cin>>n>>m;
    int a,b;
    k=s=0;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        vv[a].push_back(b);
        vv[b].push_back(a);
    }
    for(int i=1;i<=n;i++)
    {
        cin>>num[i];
        if(num[i]&1) s=i;
    }
    dfs(s);
    if(num[s])
    {
        num[s]=0;
        k--;
    }
    if(judge())
    {
        cout<<k<<endl;
        if (k)
        {
            cout<<ans[0]<<" ";
            for (int i=1;i<k;i++)cout<<ans[i]<<" ";
        }
    }
    else cout<<"-1"<<endl;
    return 0;
}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define MAXN 100005
const int INF=0x7f7f7f7f;
typedef pair<int,int> pii;
#define gc() getchar()
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=gc();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=gc();}
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=gc();}
	x*=f;
}
struct edge{int v,nxt;}e[MAXN<<1];
int n,m,x,y,sum,tot,s,a[MAXN<<2],head[MAXN];
bool vis[MAXN],c[MAXN];
void addEdge(int u,int v){e[++tot]={v,head[u]};head[u]=tot;}
void dfs(int u,int fa){
	vis[u]=1;a[++sum]=u;c[u]^=1;
	for(int i=head[u];i;i=e[i].nxt)
		if(!vis[e[i].v])
			dfs(e[i].v,u),a[++sum]=u,c[u]^=1;
	if(c[u]){a[++sum]=fa;c[fa]^=1;a[++sum]=u;c[u]^=1;}
}
signed main(){
	read(n);read(m);
	for(int i=1;i<=m;i++){
		int u,v;read(u);read(v);
		addEdge(u,v);addEdge(v,u);
	}
	for(int i=1;i<=n;i++){read(c[i]);if(c[i])s=i;}
	if(s){dfs(s,-1);for(int i=1;i<=n;i++)if(!vis[i]&&c[i]){puts("-1");return 0;}}
	if(sum>1&&a[sum-1]==-1)sum-=3;printf("%d\n",sum);
	for(int i=1;i<=sum;i++)printf("%d ",a[i]);
	return 0;
}


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

#define I inline
#define ri register int
#define int long long
#define ll long long
#define ull unsigned long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define swap(a,b) ((a)^=(b)^=(a)^=(b))
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define dow(i,a,b) for(ri i=(a);i>=(b);--i)
#define go(i,u) for(ri i=lnk[u];i;i=nxt[i])
#define mem(f,x) memset(f,x,sizeof(f))
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define vec vector
#define que queue
#define pb push_back
#define lowbit(x) (x&(-x))

I int gi(){
    int x=0;bool f=0;char ch=getchar();
    while(!isdigit(ch))f|=ch=='-',ch=getchar();
    while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}

I void pi(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)pi(x/10);
    putchar(48+x%10);
}

I void pin(int x){pi(x);putchar('\n');}
I void pib(int x){pi(x);putchar(' ');}

const int N = 2e5+5,M = N<<1;

int lnk[N],nxt[M],to[M],ec;
I void add(int u,int v){to[++ec]=v;nxt[ec]=lnk[u];lnk[u]=ec;}

int n,m;
int a[N],s,ot[N],ans;

void dfs(int u,int Fa){
    ot[++ans]=u;a[u]^=1;
    go(i,u)
    {
        int v=to[i];
        if(v==Fa)continue;
        dfs(v,u);ot[++ans]=u;a[u]^=1;
    }
    if(a[u]){ot[++ans]=Fa;a[Fa]^=1;a[u]^=1;}
}

signed main(){
    n=gi(),m=gi();
    rep(i,1,m){int u=gi(),v=gi();add(u,v);add(v,u);}
    rep(i,1,n){a[i]=gi();if(a[i])s=i;}
    if(s){dfs(s,-1);rep(i,1,n){if(a[i] && s!=i)puts("-1"),exit(0);}}
    if(ans>1&&ot[ans-1]==-1)ans=-3;
    pin(ans);
    rep(i,1,ans)pib(ot[i]);
}


#include<bits/stdc++.h>
using namespace std;
const int maxN=600005;
struct Edge
{
	int next,now;
}edge[maxN*2];
int head[maxN],cnt=0;
#define For(now) for(int _i_=head[now];_i_;_i_=edge[_i_].next)
#define Son edge[_i_].now
void add(int from,int to)
{
	edge[++cnt].next=head[from];
	head[from]=cnt;
	edge[cnt].now=to;
}
int N,M;
int val[maxN],DFS[maxN];
int answer=0;
bool visit[maxN];
void no()
{
	printf("-1");
	exit(0);
}
void dfs(int now,int father)
{
	visit[now]=1;
	DFS[++answer]=now;
	val[now]^=1;
	For(now)
	if(!visit[Son])
	{
		dfs(Son,now);
		DFS[++answer]=now;
		val[now]^=1;
	}
	if(val[now])
	{
		DFS[++answer]=father;
		val[father]^=1;
		DFS[++answer]=now;
		val[now]^=1;
	}
}
int main()
{
	scanf("%d%d",&N,&M);
	int i,from,to;
	for(i=1;i<=M;i++)
	{
		scanf("%d%d",&from,&to);
		add(from,to);
		add(to,from);
	}
	int root=0;
	for(i=1;i<=N;i++)
	{
		scanf("%d",&val[i]);
		if(val[i])root=i;
	}
	if(root)
	{
		dfs(root,-1);
		for(i=1;i<=N;i++)
		if(!visit[i]&&val[i])
		no();
	}
	if(answer>1&&DFS[answer-1]==-1)answer-=3;
	printf("%d\n",answer);
	for(i=1;i<=answer;i++)printf("%d ",DFS[i]);
}


#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
struct node{
	int to,nxt;
}e[N];
int n,m,cnt=0,ans,s,vis[N],road[N<<2];
int a[N],head[N];
void add(int u,int v){
	e[++cnt].nxt=head[u];e[cnt].to=v;head[u]=cnt;
}
void dfs(int u,int fa)
{
	vis[u]=1;road[++ans]=u;a[u]^=1;
	for(int i=head[u];i;i=e[i].nxt){
		if(!vis[e[i].to]){
			dfs(e[i].to,u); road[++ans]=u;a[u]^=1;
		}
	}
	if(a[u]){
		road[++ans]=fa;a[fa]^=1;road[++ans]=u;a[u]^=1;
	}
}
int main()
{
	cin>>n>>m;int u,v;
	for(int i=1;i<=m;i++){
		scanf("%d %d",&u,&v);
		add(u,v);add(v,u);
	}
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);if(a[i]) s=i;}
	if(s) dfs(s,-1);
	for(int i=1;i<=n;i++) if(!vis[i]&&a[i]){cout<<-1;return 0;}
	if(ans>1&&road[ans-1]==-1) ans-=3;
	cout<<ans<<endl;
	for(int i=1;i<=ans;i++) printf("%d ",road[i]);
	return 0;
}


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

const int maxn=100005;

struct Edge{
	int next,to;
}edge[maxn*2];

vector<int> ans;

int n,m,nedge=0;
int head[maxn],x[maxn],vis[maxn];

void addedge(int a,int b){
	edge[nedge].to=b;
	edge[nedge].next=head[a];
	head[a]=nedge++;
}

void dfs(int v,int fa){
	vis[v]=1;
	x[v]^=1;
	ans.push_back(v);
	for (int i=head[v];i!=-1;i=edge[i].next){
		int u=edge[i].to;
		if (vis[u]) continue;
		dfs(u,v);
		ans.push_back(v);
		x[v]^=1;
	}
	if (x[v]){
		ans.push_back(fa);
		x[fa]^=1;
		ans.push_back(v);
		x[v]^=1;
	}
}

int main(){
	memset(vis,0,sizeof(vis));
	memset(head,-1,sizeof(head));
	scanf("%d%d",&n,&m);
	while(m--){
		int a,b;
		scanf("%d%d",&a,&b);
		addedge(a,b);
		addedge(b,a);
	}
	for (int i=1;i<=n;i++){
		scanf("%d",&x[i]);
	}
	int r=-1;
	for (int i=1;i<=n;i++){
		if (x[i]){
			r=i;
			break;
		}
	}
	if (r==-1){
		printf("0");
		return 0;
	}
	dfs(r,0);
	for (int i=1;i>=n;i++){
		if (x[i] && !vis[i]){
			printf("-1");
			return 0;
		}
	}
	if (ans[ans.size()-2]==0){
		printf("%d\n",ans.size()-3);
		for (int i=0;i<ans.size()-3;i++){
			printf("%d ",ans[i]);
		}
	}
	else{
		printf("%d\n",ans.size());
		for (int i=0;i<ans.size();i++){
			printf("%d ",ans[i]);
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define maxn 100000
using namespace std;
int n,m;
vector<int>E[maxn+5];
vector<int>ans;
bool vis[maxn+5];
int tim[maxn+5];
int cnt[maxn+5];
void dfs(int x,int fa){
	ans.push_back(x);
	vis[x]=1;
	cnt[x]^=1;
	for(int y : E[x]){
		if(y!=fa&&!vis[y]){
			dfs(y,x);
			ans.push_back(x);
			cnt[x]^=1;
		}
	}
	if(fa!=0&&cnt[x]==1){
		ans.push_back(fa);
		ans.push_back(x);
		cnt[fa]^=1;
		cnt[x]^=1;
	}
}
int main(){
	int u,v;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d %d",&u,&v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	for(int i=1;i<=n;i++) scanf("%d",&cnt[i]);
	int st=1;
	for(int i=1;i<=n;i++){
		if(cnt[i]==1) st=i;
	}
	dfs(st,0);
	for(int i=1;i<=n;i++){
		if(!vis[i]&&cnt[i]){
			printf("-1\n");
			return 0;
		}
	}
	int sz=ans.size();
	if(cnt[st]) sz--;
	printf("%d\n",sz);
	for(int i=0;i<sz;i++) printf("%d ",ans[i]);
}


#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
const int maxn=100100;
struct edge
{
	int to,next;
}e[maxn<<1];
int n,m,len,tot,head[maxn],c[maxn],ans[maxn]; bool f[maxn];
void insert(int x,int y)
{
	e[++len].to=y;e[len].next=head[x];head[x]=len;
}
void dfs(int x)
{
	c[x]=!c[x];ans[++tot]=x;
	f[x]=1;
	for(int i=head[x];i;i=e[i].next)
	{
		int k=e[i].to;
		if(!f[k])
		{
			dfs(k);
			c[x]=!c[x];ans[++tot]=x;
			if(c[k])
			{
				c[k]=!c[k];ans[++tot]=k;
				c[x]=!c[x];ans[++tot]=x;
			}
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;++i)
	{
		scanf("%d%d",&x,&y);
		insert(x,y);insert(y,x);
	}
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&c[i]);
	}
	for(int i=1;i<=n;++i)
	{
		if(c[i]==1)
		{
			dfs(i);
			if(c[i])
			{
				tot--;c[i]=0;
			}
			break;
		}
	}
	bool ff=0;
	for(int i=1;i<=n;++i)
	{
		if(c[i])
		{
			ff=1;break;
		}
	}
	if(ff)printf("-1\n");
	else
	{
		printf("%d\n",tot);
		for(int i=1;i<=tot;++i)printf("%d ",ans[i]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
typedef long long LL;
int readint(){
    int x=0,f=1;char s=getchar();
    #define sc (s=getchar())
    while(s<'0'||s>'9'){
        if(s=='-')
            f=-1;
        sc;
    }
    while(s>='0'&&s<='9'){
        x=(x<<3)+(x<<1)+(s^48);
        sc;
    }
    #undef sc
    return x*f;
}
int head[maxn],edge_cnt=-1;
struct edge{
    int v,nxt;
    edge(){};
    edge(int V,int N){
        v=V;
        nxt=N;
    }
}e[maxn<<1];
void addedge(int u,int v){
    e[++edge_cnt]=edge(v,head[u]);
    head[u]=edge_cnt;
    e[++edge_cnt]=edge(u,head[v]);
    head[v]=edge_cnt;
}
int deg[maxn];
bool vis[maxn];
vector<int> ans;
void dfs(int x,int fa){
    vis[x]=1;
    deg[x]^=1;
    ans.push_back(x);
    for(int i=head[x];~i;i=e[i].nxt){
        int v=e[i].v;
        if(!vis[v]&&v!=fa){
            dfs(v,x);
            ans.push_back(x);
            deg[x]^=1;
        }
    }
    if(deg[x]==1&&fa!=-1){
        deg[x]^=1;
        deg[fa]^=1;
        ans.push_back(fa);
        ans.push_back(x);
    }
}
int main (){
    memset(head,-1,sizeof(head));
    int n=readint(),m=readint();
    for(int i=1;i<=m;i++){
        int u=readint(),v=readint();
        addedge(u,v);
    }
    for(int i=1;i<=n;i++){
        deg[i]=readint();
    }
    int be=1;
    for(int i=1;i<=n;i++){
        if(deg[i]==1){
            be=i;
            break;
        }
    }
    dfs(be,-1);
    if(deg[be]==1){
        ans.resize(ans.size()-1);
    }
    bool flag=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]&&deg[i]==1){
            flag=1;
           break;
        }
    }
    if(flag){
        puts("-1");
        return 0;
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
        printf("%d ",ans[i]);
    }
    return 0;
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int n,m,a[100005],ans[400005],cnt,s;
vector<int>G[100005];
bool vis[100005];
void dfs(int step,int fa){
	vis[step] = 1;
	ans[++ cnt] = step;
	a[step] ^= 1;
	for (int i = 0;i < G[step].size();i ++){
		if (!vis[G[step][i]]){
			dfs(G[step][i],step);
			a[step] ^= 1;
			ans[++ cnt] = step;
		}
	}
	if (a[step]){
		a[fa] ^= 1;
		a[step] ^= 1;
		ans[++ cnt] = fa;
		ans[++ cnt] = step;
	}
}
int main(){
	scanf ("%d%d",&n,&m);
	for (int i = 1;i <= m;i ++){
		int a,b;
		scanf ("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for (int i = 1;i <= n;i ++){
		scanf ("%d",&a[i]);
		if (a[i])
			s = i;
	}
	if (!s){
		printf("0\n");
		return 0;
	}
	else {
		dfs(s,-1);
		if (cnt > 1 && ans[cnt - 1] == -1)
			cnt -= 3;
		printf("%d\n",cnt);
		for (int i = 1;i < cnt;i ++)
			printf("%d ",ans[i]);
		printf("%d\n",ans[cnt]);
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxN=100005;
struct Edge
{
	int next,now;
}edge[maxN*5];
int head[maxN],cnt=0;
#define For(now) for(int _i_=head[now];_i_;_i_=edge[_i_].next)
#define Son edge[_i_].now
void add(int from,int to)
{
	edge[++cnt].next=head[from];
	head[from]=cnt;
	edge[cnt].now=to;
}
int N,M;
int val[maxN],DFS[maxN];
int answer=0;
bool visit[maxN];
void no()
{
	printf("-1");
	exit(0);
}
void dfs(int now,int father)
{
	visit[now]=1;
	DFS[++answer]=now;
	val[now]^=1;
	For(now)
	if(!visit[Son])
	{
		dfs(Son,now);
		DFS[++answer]=now;
		val[now]^=1;
	}
	if(val[now])
	{
		DFS[++answer]=father;
		val[father]^=1;
		DFS[++answer]=now;
		val[now]^=1;
	}
}
int main()
{
	scanf("%d%d",&N,&M);
	int i,from,to;
	for(i=1;i<=M;i++)
	{
		scanf("%d%d",&from,&to);
		add(from,to);
		add(to,from);
	}
	int root=0;
	for(i=1;i<=N;i++)
	{
		scanf("%d",&val[i]);
		if(val[i])root=i;
	}
	if(root)
	{
		dfs(root,-1);
		for(i=1;i<=N;i++)
		if(!visit[i]&&val[i])
		no();
	}
	if(answer>1&&DFS[answer-1]==-1)answer-=3;
	printf("%d\n",answer);
	for(i=1;i<=answer;i++)printf("%d ",DFS[i]);
}


//要求把整个序列变为0
//先dfs随便生成一个树，如果回溯时发现不满足奇偶要求，就多走一个来回，这个点变为正确的奇偶性
//父节点多走了两次奇偶性不变，最后特判根节点
#include<bits/stdc++.h>
using namespace std;
int n,m,idx,cnt,st;
int opt[1000010],head[1000010],vis[1000010],ans[1000010];
struct node{
	int nxt,to;
}edge[10000010];
void add(int u,int v)
{
	edge[++idx].nxt=head[u];
	edge[idx].to=v;
	head[u]=idx;
}
void dfs(int x,int fath)
{
	opt[x]^=1;
	vis[x]=1;//防止死循环并且在后面判断是否联通
	ans[++cnt]=x;//答案数组
	for(int i=head[x];i;i=edge[i].nxt)
	{
		int v=edge[i].to;
		if(!vis[v])
		{
			dfs(v,x);
			opt[x]^=1;
			ans[++cnt]=x;
		}
	}
	if(fath!=0&&opt[x])//不是根节点，dfs完一遍之后不满足奇偶性
	{
		ans[++cnt]=fath;
		ans[++cnt]=x;
		opt[fath]^=1;
		opt[x]^=1;
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&opt[i]);
		if(opt[i])//找一个奇数点作为根节点
		st=i;
	}
	if(st)
	{
		dfs(st,0);//随便dfs生成一棵树
		for(int i=1;i<=n;i++)
		{
			if(!vis[i]&&opt[i])//如果整个图不连通并且其中有要求经过奇数次的点
			{
				printf("-1");
				return 0;
			}
		}
	}
	if(opt[st])//特判根节点
	cnt--;
	cout<<cnt<<endl;
	for(int i=1;i<=cnt;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}


//要求把整个序列变为0
#include<bits/stdc++.h>
using namespace std;
int n,m,idx,cnt,st;
int opt[100010],head[100010],vis[100010],ans[100010];
struct node{
	int nxt,to;
}edge[1000010];
void add(int u,int v)
{
	edge[++idx].nxt=head[u];
	edge[idx].to=v;
	head[u]=idx;
}
void dfs(int x,int fath)
{
	opt[x]^=1;
	vis[x]=1;//防止死循环并且在后面判断是否联通
	ans[++cnt]=x;//答案数组
	for(int i=head[x];i;i=edge[i].nxt)
	{
		int v=edge[i].to;
		if(!vis[v])
		{
			dfs(v,x);
		}
	}
	if(opt[x])//dfs完一遍之后不满足奇偶性
	{
		if(!fath)
		cnt--;
		else//把当前这个点调整为正确的奇偶性，让他父节点多走一次，把错误转移到父节点，最后到根节点
		{
			opt[fath]^=1;
			opt[x]^=1;
			ans[++cnt]=fath;
			ans[++cnt]=x;
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&opt[i]);
		if(opt[i])//找一个奇数点作为根节点
		st=i;
	}
	if(st)
	{
		dfs(st,0);//随便dfs生成一棵树
		for(int i=1;i<=n;i++)
		{
			if(!vis[i]&&opt[i])//如果整个图不连通并且其中有要求经过奇数次的点
			{
				printf("-1");
				return 0;
			}
		}
	}
	cout<<cnt<<endl;
	for(int i=1;i<=cnt;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}


//要求把整个序列变为0
//先dfs随便生成一个树，如果回溯时发现不满足奇偶要求，就多走一个来回，这个点变为正确的奇偶性
//父节点多走了两次奇偶性不变，最后特判根节点
#include<bits/stdc++.h>
using namespace std;
int n,m,idx,cnt,st;
int opt[100010],head[100010],vis[100010],ans[100010];
struct node{
	int nxt,to;
}edge[1000010];
void add(int u,int v)
{
	edge[++idx].nxt=head[u];
	edge[idx].to=v;
	head[u]=idx;
}
void dfs(int x,int fath)
{
	opt[x]^=1;
	vis[x]=1;//防止死循环并且在后面判断是否联通
	ans[++cnt]=x;//答案数组
	for(int i=head[x];i;i=edge[i].nxt)
	{
		int v=edge[i].to;
		if(!vis[v])
		{
			dfs(v,x);
			opt[x]^=1;
			ans[++cnt]=x;
		}
	}
	if(fath!=0&&opt[x])//不是根节点，dfs完一遍之后不满足奇偶性
	{
		ans[++cnt]=fath;
		ans[++cnt]=x;
		opt[fath]^=1;
		opt[x]^=1;
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&opt[i]);
		if(opt[i])//找一个奇数点作为根节点
		st=i;
	}
	if(st)
	{
		dfs(st,0);//随便dfs生成一棵树
		for(int i=1;i<=n;i++)
		{
			if(!vis[i]&&opt[i])//如果整个图不连通并且其中有要求经过奇数次的点
			{
				printf("-1");
				return 0;
			}
		}
	}
	if(opt[st])//特判根节点
	cnt--;
	cout<<cnt<<endl;
	for(int i=1;i<=cnt;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}


#include <iostream>
#include <vector>
#define MAXN 100005
using namespace std;

int n,m;
bool vis[MAXN] = {0};
int ans[MAXN * 4], e_o[MAXN];
vector<int> g[MAXN];
int count = 0;

bool judge() {
	for(int i=1;i<=n;i++)
		if(e_o[i])
			return false;
	return true;
}

void add_to_path(int u) {
	ans[count++] = u;
	e_o[u] ^= 1;
}

void dfs(int u) {
	vis[u] = true;
	add_to_path(u);

	int temp;
	for(int i=0;i<g[u].size();i++) {
		temp = g[u][i];
		if(vis[temp])
			continue;
		dfs(temp);
		add_to_path(u);
		if(e_o[temp]) {
			add_to_path(temp);
			add_to_path(u);
		}
	}
}

int main() {
	cin >> n >> m;
	int a,b;
	for(int i=0;i<m;i++) {
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	int start = 0;
	for(int i=1;i<=n;i++) {
		cin >> e_o[i];
		if(e_o[i] && start == 0)
			start = i;
	}

	dfs(start);

	if(e_o[start]) {
		e_o[start] = 0;
		count--;
	}

	if(judge()) {
		cout << count << endl;
		for(int i=0;i<count;i++)
			cout << ans[i] << ' ';
		cout << endl;
	}
	else
		cout << "-1" << endl;

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
#define N 100010

vector<int>G[N];
int ans[N*4];

bool vis[N],c[N];
int cnt;

void v(int x){
     ans[cnt++]=x;
     c[x]^=1;
}

void dfs(int x){
     vis[x]=1;
     v(x);
     for(int i=0;i<G[x].size();i++){
         if(vis[G[x][i]]) continue;
         dfs(G[x][i]);
         v(x);
         if(c[G[x][i]]){
            v(G[x][i]);
            v(x);
         }
     }
}

bool judge(int n){
     for(int i=1;i<=n;i++) if(c[i]) return false;
    return true;
}

int main()
{
    int n,m,u,v;
    cnt=0;
    memset(vis,0,sizeof(vis));
    cin>>n>>m;
    for(int i=0;i<m;i++){
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int st=-1;
    for(int i=1;i<=n;i++){
        scanf("%d",&u);
        c[i]=u;
        if(st==-1&&u){
            st=i;
        }
    }
    dfs(st);
    if(c[st]){
        c[st]=0;
        cnt--;
    }
    if(judge(n)){
        printf("%d\n",cnt);
        for(int i=0;i<cnt;i++){
            printf("%d ",ans[i]);
        }
        printf("\n");
    }
    else printf("-1\n");
    return 0;
}


#include <iostream>
#include <vector>
#define MAXN 100005
using namespace std;

int n,m;
bool vis[MAXN] = {0};
int ans[MAXN * 4], e_o[MAXN];
vector<int> g[MAXN];
int count = 0;

bool judge() {
	for(int i=1;i<=n;i++)
		if(e_o[i])
			return false;
	return true;
}

void add_to_path(int u) {
	ans[count++] = u;
	e_o[u] ^= 1;
}

void dfs(int u) {
	vis[u] = true;
	add_to_path(u);

	int temp;
	for(int i=0;i<g[u].size();i++) {
		temp = g[u][i];
		if(vis[temp])
			continue;
		dfs(temp);
		add_to_path(u);
		if(e_o[temp]) {
			add_to_path(temp);
			add_to_path(u);
		}
	}
}

int main() {
	cin >> n >> m;
	int a,b;
	for(int i=0;i<m;i++) {
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	int start = 0;
	for(int i=1;i<=n;i++) {
		cin >> e_o[i];
		if(e_o[i] && start == 0)
			start = e_o[i];
	}

	dfs(start);

	if(e_o[start]) {
		e_o[start] = 0;
		count--;
	}

	if(judge()) {
		cout << count << endl;
		for(int i=0;i<count;i++)
			cout << ans[i] << ' ';
		cout << endl;
	}
	else
		cout << "-1" << endl;

	return 0;
}


#include <iostream>
#include <vector>
#define MAXN 100005
using namespace std;

int n,m;
bool vis[MAXN] = {0};
int ans[MAXN * 4], e_o[MAXN];
vector<int> g[MAXN];
int count = 0;

bool judge() {
	for(int i=0;i<n;i++)
		if(e_o[i])
			return false;
	return true;
}

void add_to_path(int u) {
	ans[count++] = u;
	e_o[u] ^= 1;
}

void dfs(int u) {
	vis[u] = true;
	add_to_path(u);

	int temp;
	for(int i=0;i<g[u].size();i++) {
		temp = g[u][i];
		if(vis[temp])
			continue;
		dfs(temp);
		add_to_path(u);
		if(e_o[temp]) {
			add_to_path(temp);
			add_to_path(u);
		}
	}
}

int main() {
	cin >> n >> m;
	int a,b;
	for(int i=0;i<m;i++) {
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	int start = 0;
	for(int i=1;i<=n;i++) {
		cin >> e_o[i];
		if(e_o[i] && start == 0)
			start = e_o[i];
	}

	dfs(start);

	if(e_o[0]) {
		e_o[0] = 0;
		count--;
	}

	if(judge()) {
		cout << count << endl;
		for(int i=0;i<count;i++)
			cout << ans[i] << ' ';
		cout << endl;
	}
	else
		cout << "-1" << endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define SIZE 100010
int Ver[SIZE],Next[SIZE],Head[SIZE];
int tot=0;
int a[SIZE],vis[SIZE];
int n,m;
int cnt=0;
int Ans[SIZE],dep[SIZE],fa[SIZE];
int find(int x){
	return fa[x]==x? x:(fa[x]=find(fa[x]));
}
void Add(int x,int y){
	Ver[++tot]=y;
	Next[tot]=Head[x];
	Head[x]=tot;
}
int check(){
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]==1&&vis[i]%2==0) ans++;
		else if(a[i]==0&&vis[i]%2==1) ans++;
	}
	return ans;
}
void dfs(int x,int fa){
	if(check()==0) return;
	Ans[++cnt]=x;
	vis[x]++;
	if(check()==0) return ;
	if(dep[x]==1&&fa!=0){
		if(check()==0) return;
		if(a[x]%2==0){
			if(check()==0) return;
			if(vis[x]%2==1)dfs(fa,0);
			else{
				if(check()==0) return;
				Ans[++cnt]=fa;
				vis[fa]++;
				return;
			}
		}
		else {
			if(check()==0) return;
			Ans[++cnt]=fa;
			vis[fa]++;
			return ;
		}
	}
	else{
		if(check()==0) return;
		if(a[x]%2==1&&vis[x]%2==0){
			if(fa!=0) dfs(fa,x);
			else{
				if(check()==0) return;
				for(int i=Head[x];i;i=Next[i]){
					if(check()==0) return;
					int y=Ver[i];
					if(y==0) continue;
					if(check()==0) return;
					if(a[y]%2==0&&vis[y]%2==0&&vis[2]) continue;
					if(a[y]%2==1&&vis[y]%2==1) continue;
					if(check()==0) return;
					if(a[y]%2==1){
						if(check()==0) return;
						dfs(y,x);
						break;
					}
					if(check()==0) return;
//					Ans[++cnt]=x;
				}
			}
			return;
		}
	}
	for(int i=Head[x];i;i=Next[i]){
		if(check()==0) return;
		int y=Ver[i];
		if(vis[y]>=4) continue;
		if(check()==0) return;
		if(y==fa||y==0)continue;
		dfs(y,x);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		if(find(x)==find(y)) continue;
		if(tot/2==n-1) break;
		fa[find(y)]=find(x);
		Add(x,y);Add(y,x);
		dep[x]++;dep[y]++;
	}

	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	dfs(1,0);
//	for(int i=1;i<=n;i++) cout<<vis[i]<<"";
//	cout<<endl;
//	cout<<check()<<"hahahahahahhaahaha"<<endl;
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++) printf("%d ",Ans[i]);
	return 0;
}


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

const int maxn=100005;

struct Edge{
    int next,to;
}edge[maxn*2];

vector<int> ans;

int n,m,nedge=0;
int head[maxn],x[maxn],vis[maxn];

void addedge(int a,int b){
    edge[nedge].to=b;
    edge[nedge].next=head[a];
    head[a]=nedge++;
}

void dfs(int v,int fa){
    vis[v]=1;
    x[v]^=1;
    ans.push_back(v);
    for (int i=head[v];i!=-1;i=edge[i].next){
        int u=edge[i].to;
        if (vis[u]) continue;
        dfs(u,v);
        ans.push_back(v);
        x[v]^=1;
    }
    if (x[v]){
        ans.push_back(fa);
        x[fa]^=1;
        ans.push_back(v);
        x[v]^=1;
    }
}

int check(int v){
    vis[v]=1;
    for (int i=head[v];i!=-1;i=edge[i].next){
        int u=edge[i].to;
        if (!vis[u]) check(u);
    }
}

int main(){
    memset(vis,0,sizeof(vis));
    memset(head,-1,sizeof(head));
    scanf("%d%d",&n,&m);
    while(m--){
        int a,b;
        scanf("%d%d",&a,&b);
        addedge(a,b);
        addedge(b,a);
    }
    for (int i=1;i<=n;i++){
        scanf("%d",&x[i]);
    }
    int r=-1;
    for (int i=1;i<=n;i++){
        if (x[i]){
            r=i;
            break;
        }
    }
    if (r==-1){
        printf("0");
        return 0;
    }
    check(r);
    for (int i=1;i<=n;i++){
        if (x[i] && !vis[i]){
            printf("-1");
            return 0;
        }
    }
    memset(vis,0,sizeof(vis));
    dfs(1,0);
    if (ans[ans.size()-2]==0){
        printf("%d\n",ans.size()-3);
        for (int i=0;i<ans.size()-3;i++){
            printf("%d ",ans[i]);
        }
    }
    else{
        printf("%d\n",ans.size());
        for (int i=0;i<ans.size();i++){
            printf("%d ",ans[i]);
        }
    }
    return 0;
}


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

#define I inline
#define ri register int
#define int long long
#define ll long long
#define ull unsigned long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define swap(a,b) ((a)^=(b)^=(a)^=(b))
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define dow(i,a,b) for(ri i=(a);i>=(b);--i)
#define go(i,u) for(ri i=lnk[u];i;i=nxt[i])
#define mem(f,x) memset(f,x,sizeof(f))
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define vec vector
#define que queue
#define pb push_back
#define lowbit(x) (x&(-x))

I int gi(){
    int x=0;bool f=0;char ch=getchar();
    while(!isdigit(ch))f|=ch=='-',ch=getchar();
    while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}

I void pi(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)pi(x/10);
    putchar(48+x%10);
}

I void pin(int x){pi(x);putchar('\n');}
I void pib(int x){pi(x);putchar(' ');}

const int N = 4e5+5,M = N<<1;

int lnk[N],nxt[M],to[M],ec;
I void add(int u,int v){to[++ec]=v;nxt[ec]=lnk[u];lnk[u]=ec;}

int n,m;
int a[N],s,ot[N],ans,vis[N];

void dfs(int u,int Fa){
    ot[++ans]=u;a[u]^=1;vis[u]=1;
    go(i,u)
    {
        int v=to[i];
        if(vis[v])continue;
        dfs(v,u);ot[++ans]=u;a[u]^=1;
    }
    if(a[u]){ot[++ans]=Fa;a[Fa]^=1;ot[++ans]=u;a[u]^=1;}
}

signed main(){
    n=gi(),m=gi();
    rep(i,1,m){int u=gi(),v=gi();add(u,v);add(v,u);}
    rep(i,1,n){a[i]=gi();if(a[i])s=i;}
    if(s){dfs(s,-1);rep(i,1,n){if(a[i] && !vis[i])puts("-1"),exit(0);}}
    if(ans>1&&ot[ans-1]==-1)ans-=3;
    pin(ans);
    rep(i,1,ans)pib(ot[i]);
}


#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<iostream>
using namespace std;
int n,m;
const int N=100100;
int b[N];
struct by
{
	int to,nxt;
}e[2*N];
int head[N];
int tot=0;
int stack[N];
int ans=0;
void add(int x,int y)
{
	tot++;
	e[tot].to=y;
	e[tot].nxt=head[x];
	head[x]=tot;
}
bool vis[N];
void dfs(int x,int fa)
{
	vis[x]=1; stack[++ans]=x; b[x]^=1;
	for(int i=head[x];i;i=e[i].nxt)
	if(!vis[e[i].to])
	  dfs(e[i].to,x),stack[++ans]=x,b[x]^=1;
	if(b[x]) {stack[++ans]=fa; b[fa]^=1; stack[++ans]=x; b[x]^=1; }
}
int main()
{
	cin>>n>>m;
	int u,v;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	int st=0;
	for(int i=1;i<=n;i++)  {scanf("%d",&b[i]);if(b[i])st=i;}
    if(st)  {dfs(st,-1);for(int i=1;i<=n;i++)  if(!vis[i] && b[i]) {printf("-1\n");return 0;}}
    if(ans>1 && stack[ans-1]==-1)  ans-=3;//删除一次震荡和回溯
	printf("%d\n",ans);
	for(int i=1;i<=ans;i++)  printf("%d ",stack[i]);
//	printf("\n");
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

#define M 100005

vector <int> G[M];
int n, m, st, x[M], cnt, ans[M * 4], now[M];
bool vis[M];

void dfs (int Index, int fa){
    vis[Index] = 1;
    ans[++ cnt] = Index;
    now[Index] ^= 1;
    for (int i = 0; i < G[Index].size (); i ++){
        int tmp = G[Index][i];
        if (! vis[tmp]){
            dfs (tmp, Index);
            now[Index] ^= 1;
            ans[++ cnt] = Index;
        }
    }
    if (Index != st){
        if (now[Index] != x[Index]){
            ans[++ cnt] = fa;
            ans[++ cnt] = Index;
            now[fa] ^= 1;
        }
    }
    else{
        if(now[Index] != x[Index]){
            cnt --;
        }
    }
}
int main (){
    scanf ("%d %d", &n, &m);
    for (int i = 1; i <= m; i ++){
        int u, v;
        scanf ("%d %d", &u, &v);
        G[u].push_back (v);
        G[v].push_back (u);
    }
    for (int i = 1; i <= n; i ++){
        scanf ("%d", &x[i]);
        if (x[i])
            st = x[i];
    }
    dfs (st, 0);
    for (int i = 1; i <= n; i ++){
        if (! vis[i] && x[i]){
            printf ("-1\n");
            return 0;
        }
    }
    printf ("%d\n", cnt);
    for (int i = 1; i <= cnt; i ++)
        printf ("%d ", ans[i]);
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<cctype>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
int n,m,biao[100010],ji,chu[500010],zh[100010],f[100010],minx=1000000000,s;
vector<int>cun[100010];
void dfs(int xu,int fa){
	int o=0;
	biao[xu]=1;
	chu[++ji]=xu;
	for(int j=0;j<cun[xu].size();j++)
		if(!biao[cun[xu][j]]){
			o=1;
			dfs(cun[xu][j],xu);
		}
	if(!o)zh[xu]^=1;
	else chu[++ji]=xu;
	if(zh[xu]==1){
		chu[++ji]=fa;
		chu[++ji]=xu;
		zh[fa]^=1;
		zh[xu]^=1;
	}
}
inline int read(){
	int date=0,w=1;char c=0;
	while(!isdigit(c)){if(c=='-')w=-1;c=getchar();}
	while(isdigit(c)){date=date*10+c-'0';c=getchar();}
	return date*w;
}
int main(){
	n=read();
	m=read();
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		cun[x].push_back(y);
		cun[y].push_back(x);
		++f[x];
		++f[y];
	}
	for(int i=1;i<=n;i++){
		zh[i]=read();
		if(minx>f[i]){
			minx=f[i];
			s=i;
		}
	}
	biao[s]=1;
	for(int i=0;i<cun[s].size();i++){
		chu[++ji]=s;
		zh[s]^=1;
		dfs(cun[s][i],s);
	}
	if(zh[s]==1)chu[++ji]=s;
	printf("%d\n",ji);
	for(int i=1;i<=ji;i++)
		printf("%d ",chu[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
struct node{
	int to,nxt;
}e[N];
int n,m,cnt=0,ans,s,vis[N],road[N<<2];
int a[N],head[N];
void add(int u,int v){
	e[++cnt].nxt=head[u];e[cnt].to=v;head[u]=cnt;
}
void dfs(int u,int fa)
{
	vis[u]=1;road[++ans]=u;a[u]^=1;
	for(int i=head[u];i;i=e[i].nxt){
		if(!vis[e[i].to]){
			dfs(e[i].to,u); road[++ans]=u;a[u]^=1;
		}
	}
	if(a[u]){
		road[++ans]=fa;a[fa]^=1;road[++ans]=u;a[u]^=1;
	}
}
int main()
{
	cin>>n>>m;int u,v;
	for(int i=1;i<=m;i++){
		scanf("%d %d",&u,&v);
		add(u,v);add(v,u);
	}
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);if(a[i]) s=i;}
	if(s) dfs(s,-1);
	for(int i=1;i<=n;i++) if(!vis[i]&&a[i]){cout<<-1;return 0;}
	if(ans>1&&road[ans-1]==-1) ans-=3;
	cout<<ans<<endl;
	for(int i=1;i<=ans;i++) printf("%d ",road[i]);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m,u,v,s,tot;
int a[N],c[N],ans[N<<2];
bool vis[N];
int cnt,head[N];
struct edge{int next,to;}e[N<<1];

inline void add(int u,int v)
{
	cnt++;
	e[cnt].next=head[u];
	e[cnt].to=v;
	head[u]=cnt;
}

void dfs(int u,int fa)
{
	vis[u]=true; c[u]^=1; ans[++tot]=u;
	for (register int i=head[u]; i; i=e[i].next)
	if (!vis[e[i].to])
	{
		dfs(e[i].to,u);
		c[u]^=1; ans[++tot]=u;
	}
	if (c[u]) c[fa]^=1,ans[++tot]=fa,c[u]^=1,ans[++tot]=u;
}

int main(){
	scanf("%d%d",&n,&m);
	for (register int i=1; i<n; ++i) scanf("%d%d",&u,&v),add(u,v),add(v,u);
	for (register int i=1; i<=n; ++i)
	{
		scanf("%d",&c[i]);
		if (c[i] && !s) s=i;
	}
	dfs(s,0);
	for (register int i=1; i<=n; ++i) if (c[i]) {puts("-1"); return 0;}
	if (tot>1 && ans[tot-1]==0) tot-=3;
	printf("%d\n",tot);
	for (register int i=1; i<=tot; ++i) printf("%d ",ans[i]); puts("");
return 0;
}


#include<bits/stdc++.h>

#define ll long long
#define re register int
#define For(i,a,b) for(ll i=(a); i<=(b); i++)
const int INF=1<<30;
const int mod=1e9+3;
using namespace std;
template <typename T>
inline void read(T &x) {
	x = 0;
	ll f = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') f = -1;
			ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + (ch ^ 48);
		ch = getchar();
	}
	x *= f;
	return;
}
template <typename T>
inline void write(T x){
	if(x < 0) {
		putchar('-');
		x = -x;
	}
	if(x > 9)
		write(x/10);
	putchar(x % 10 + '0');
	return;
}
inline ll qpow(ll a,ll b){
	ll x=1,y=a;
	while(b>=1){
		if(b%2==1) x=x*y%mod;
		y=y*y%mod;
		b/=2;
	}
	return x;
}
struct fuck{
	int next,to;
}you[100005];
int head[100005],n,m;
int q[100005];
int a[100005],s;
int tot=0,ans;
bool vis[100005],c[100005];
inline void add(int u,int v){
	++tot;
	you[tot].to=v;
	you[tot].next=head[u];
	head[u]=tot;
}
inline dfs(int s,int fa){
	vis[s]=1;
	a[++ans]=s;
	c[s]^=1;
	for(int i=head[s];i;i=you[i].next){
		if(!vis[you[i].to]){
			dfs(you[i].to,s);
			a[++ans]=s;
			c[s]^=1;
		}
	}
	if(c[s]){
		a[++ans]=fa;
		c[fa]^=1;
		a[++ans]=s;
		c[s]^=1;
	}
}
int main(){
	#ifndef ONLINE_JUDGE
		freopen("a.in","r",stdin);
		freopen("a.out","w",stdout);
	#endif
	int x,y;
	read(n);
	read(m);
	For(i,1,m){
		read(x);
		read(y);
		add(x,y);
		add(y,x);
	}
	For(i,1,n){
		read(q[i]);
		if(q[i]==1){
			s=i;
		}
	}
	if(s){
		dfs(s,-1);
		For(i,1,n){
			if(!vis[i]&&q[i]){
				puts("-1");
				return 0;
			}
		}
	}
	if(ans>1&&a[ans-1]==-1){
		ans-=3;
	}
	write(ans);
	puts("");
	For(i,1,ans){
		printf("%d ",a[i]);
	}
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

#define M 100005

vector <int> G[M];
int n, m, st, x[M], cnt, ans[M * 4], now[M];
bool vis[M];

void dfs (int Index, int fa){
    vis[Index] = 1;
    ans[++ cnt] = Index;
    now[Index] ^= 1;
    for (int i = 0; i < G[Index].size (); i ++){
        int tmp = G[Index][i];
        if (! vis[tmp]){
            dfs (tmp, Index);
            now[Index] ^= 1;
            ans[++ cnt] = Index;
        }
    }
    if (now[Index] != x[Index]){
        ans[++ cnt] = fa;
        ans[++ cnt] = Index;
        now[fa] ^= 1;
        now[Index] ^= 1;
    }
}
int main (){
    scanf ("%d %d", &n, &m);
    for (int i = 1; i <= m; i ++){
        int u, v;
        scanf ("%d %d", &u, &v);
        G[u].push_back (v);
        G[v].push_back (u);
    }
    for (int i = 1; i <= n; i ++){
        scanf ("%d", &x[i]);
        if (x[i])
            st = i;
    }
    dfs (st, 0);
    for (int i = 1; i <= n; i ++){
        if (! vis[i] && x[i]){
            printf ("-1\n");
            return 0;
        }
    }
    if (cnt > 1 && ans[cnt - 1] == 0)
        cnt -= 3;
    printf ("%d\n", cnt);
    for (int i = 1; i <= cnt; i ++)
        printf ("%d ", ans[i]);
    return 0;
}
/*
2 0
0 1
*/


#include <bits/stdc++.h>
using namespace std;
int n,m;
int x[100005] , tk[100005] ;
vector<int>adj[100005],ans;
void go(int u)
{
    tk[u]++;
    for(int v :  adj[u])
    {
        if(tk[v]==0)
        {
            ans.push_back(v);
            go(v);
            ans.push_back(u);
            tk[u]++;
            if((tk[v]&1)!=x[v])tk[v]++,tk[u]++,ans.push_back(v),ans.push_back(u);
        }
    }
}
int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int u , v;
        scanf("%d %d",&u,&v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int root=0 ;
    for(int i = 1 ; i <= n ; i++){scanf("%d",&x[i]);if(x[i])root=i;}
    if(root==0){printf("0");return 0;}
    ans.push_back(root);
    go(root);
    if((tk[root]&1)!=x[root])ans.pop_back(),tk[root]--;
    for(int i=0;i<=n;i++)if((tk[i]&1)!=x[i]){printf("-1");return 0;}
    printf("%d\n",ans.size());
    for(int u: ans)printf("%d ",u);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,lol;
int x[100005] , tk[100005] ;
vector<int>adj[100005],ans;
void go(int u)
{
    tk[u]++;
    for(int v :  adj[u])
    {
        if(tk[v]==0)
        {
            ans.push_back(v);
            go(v);
            ans.push_back(u);
            tk[u]++;
            if((tk[v]&1)!=x[v])tk[v]++,tk[u]++,ans.push_back(v),ans.push_back(u);
        }
    }
}
int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int u , v;
        scanf("%d %d",&u,&v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int root=0 ;
    for(int i = 1 ; i <= n ; i++){scanf("%d",&x[i]);if(x[i])root=i;}
    if(root==0){printf("0");return 0;}
    ans.push_back(root);
    go(root);
    if((tk[root]&1)!=x[root])ans.pop_back(),tk[root]--;
    for(int i=0;i<=n;i++)if((tk[i]&1)!=x[i]){printf("-1");return 0;}
    if(ans.size()>=3*n)printf("%d\n", 1/lol);
    printf("%d\n",ans.size());
    for(int u: ans)printf("%d ",u);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,m;
int x[100005] , tk[100005] ;
vector<int>adj[100005],ans;
void go(int u)
{
    tk[u]++;
    for(int v :  adj[u])
    {
        if(tk[v]==0)
        {
            ans.push_back(v);
            go(v);
            ans.push_back(u);
            tk[u]++;
            if((tk[v]&1)!=x[v])tk[v]++,tk[u]++,ans.push_back(v),ans.push_back(u);
        }
    }
}
int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int u , v;
        scanf("%d %d",&u,&v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int root=0 ;
    for(int i = 1 ; i <= n ; i++){scanf("%d",&x[i]);if(x[i])root=i;}
    if(root==0){printf("0");return 0;}
    ans.push_back(root);
    go(root);
    if((tk[root]&1)!=x[root])ans.pop_back(),tk[root]--;
    for(int i=0;i<=n;i++)if((tk[i]&1)!=x[i]){printf("-1");return 0;}
    assert(ans.size>=3*n);
    printf("%d\n",ans.size());
    for(int u: ans)printf("%d ",u);
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define INF 1000000000
#define FOR(i, a, b) for(int i=int(a); i<int(b); i++)
#define FORC(cont, it) for(decltype((cont).begin()) it = (cont).begin(); it != (cont).end(); it++)
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define maxN 100000

vi edges[maxN], path;
int N, M, x[maxN], vis[maxN], cur[maxN];

void dfs(int n, int p) {
	if (vis[n]) return;
	vis[n] = true;
	x[n] = !x[n];
	path.push_back(n);
	FOR(i, 0, edges[n].size()) {
		int next = edges[n][i];
		if (next == p) continue;
		dfs(next, n);
	}
	if (x[n] && ~p) {
		path.push_back(p);
		path.push_back(n);
		x[n] = !x[n];
		x[p] = !x[p];
	}
	if (~p) path.push_back(p), x[p] = !x[p];
}

int main() {
	int u, v;
	while (scanf("%d %d", &N, &M) != EOF) {
		path.clear();
		FOR(i, 0, N) edges[i].clear(), vis[i] = false;
		FOR(i, 0, M) {
			scanf("%d %d", &u, &v);
			u--, v--;
			edges[u].pb(v);
			edges[v].pb(u);
		}
		FOR(i, 0, N) scanf("%d", x + i);
		int nc = 0;
		dfs(0, -1);
		FOR(i, 1, N) if (x[i]) nc = INF;
		int st = 0;
		if (x[0]) st = 1;
		if (nc > 1) printf("-1\n");
		else {
			printf("%d\n", path.size() - st);
			FOR(i, st, path.size()) printf("%d%c", path[i] + 1, " \n"[i == path.size() - 1]);
		}
	}
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define INF 1000000000
#define FOR(i, a, b) for(int i=int(a); i<int(b); i++)
#define FORC(cont, it) for(decltype((cont).begin()) it = (cont).begin(); it != (cont).end(); it++)
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define maxN 100000

vi edges[maxN], path;
int N, M, x[maxN], vis[maxN], cur[maxN];

void dfs(int n, int p) {
	if (vis[n]) return;
	vis[n] = true;
	x[n] = !x[n];
	path.push_back(n);
	FOR(i, 0, edges[n].size()) {
		int next = edges[n][i];
		if (next == p) continue;
		dfs(next, n);
	}
	if (x[n] && ~p) {
		path.push_back(p);
		path.push_back(n);
		x[n] = !x[n];
		x[p] = !x[p];
	}
	if (~p) path.push_back(p), x[p] = !x[p];
}

int main() {
	int u, v;
	while (scanf("%d %d", &N, &M) != EOF) {
		path.clear();
		FOR(i, 0, N) edges[i].clear(), vis[i] = false;
		FOR(i, 0, M) {
			scanf("%d %d", &u, &v);
			u--, v--;
			edges[u].pb(v);
			edges[v].pb(u);
		}
		int r = 0;
		FOR(i, 0, N) {
			scanf("%d", x + i);
			if (x[i]) r = i;
		}
		int nc = 0;
		dfs(r, -1);
		FOR(i, 0, N) {
			if (r != i && x[i]) nc = INF;
		}
		int st = 0;
		if (x[r]) st = 1;
		if (nc > 1) printf("-1\n");
		else {
			printf("%d\n", path.size() - st);
			FOR(i, st, path.size()) printf("%d%c", path[i] + 1, " \n"[i == path.size() - 1]);
		}
	}
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define INF 1000000000
#define FOR(i, a, b) for(int i=int(a); i<int(b); i++)
#define FORC(cont, it) for(decltype((cont).begin()) it = (cont).begin(); it != (cont).end(); it++)
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define maxN 100000

vi edges[maxN], path;
int N, M, x[maxN], vis[maxN], cur[maxN];

void dfs(int n, int p) {
	if (vis[n]) return;
	vis[n] = true;
	x[n] = !x[n];
	path.push_back(n);
	FOR(i, 0, edges[n].size()) {
		int next = edges[n][i];
		if (next == p) continue;
		dfs(next, n);
	}
	if (x[n] && ~p) {
		path.push_back(p);
		path.push_back(n);
		x[n] = !x[n];
		x[p] = !x[p];
	}
	if (~p) path.push_back(p), x[p] = !x[p];
}

int main() {
	int u, v;
	while (scanf("%d %d", &N, &M) != EOF) {
		path.clear();
		FOR(i, 0, N) edges[i].clear(), vis[i] = false;
		FOR(i, 0, M) {
			scanf("%d %d", &u, &v);
			u--, v--;
			edges[u].pb(v);
			edges[v].pb(u);
		}
		int r = 0;
		FOR(i, 0, N) {
			scanf("%d", x + i);
			if (x[i]) r = i;
		}
		int nc = 0;
		dfs(r, -1);
		FOR(i, 0, N) {
			if (r != i && x[i]) nc = INF;
		}
		int st = 0;
		if (x[0]) st = 1;
		if (nc > 1) printf("-1\n");
		else {
			printf("%d\n", path.size() - st);
			FOR(i, st, path.size()) printf("%d%c", path[i] + 1, " \n"[i == path.size() - 1]);
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int sum=0;
    char c=getchar();
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)){
        sum=sum*10+(c^48);
        c=getchar();
    }
    return sum;
}
int const maxn=4e5+5;
int n,m,cnt,len,ans[maxn],H[maxn],c[maxn];
bool vis[maxn];
struct Edge{
    int next,to;
}E[maxn<<1];
inline void add(int a,int b){
    E[++cnt]=(Edge){H[a],b};
    H[a]=cnt;
}
void dfs(int x,int fa){
    vis[x]=true;
    ans[++len]=x;
    c[x]^=1;
    for(int i=H[x];i;i=E[i].next){
        int y=E[i].to;
        if(vis[y]) continue;
        dfs(y,x);
        ans[++len]=x;
        c[x]^=1;
    }
    if(c[x]) ans[++len]=fa,ans[++len]=x,c[x]^=1,c[fa]^=1;
}
int main(){
    n=read(),m=read();
    for(int i=1;i<=m;i++){
        int x=read(),y=read();
        add(x,y),add(y,x);
    }
    int start=1;
    for(int i=1;i<=n;i++){
        c[i]=read();
        if(c[i]) start=i;
    }
    dfs(start,0);
    for(int i=1;i<=n;i++)
      if(c[i] && !vis[i]){
          printf("-1\n");
          return 0;
      }
    if(len>1 && ans[len-1]==0)
      len-=3;
    printf("%d\n",len);
    for(int i=1;i<=len;i++)
      printf("%d ",ans[i]);
    putchar('\n');
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int sum=0;
    char c=getchar();
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)){
        sum=sum*10+(c^48);
        c=getchar();
    }
    return sum;
}
int const maxn=1e5+5;
int n,m,cnt,len,ans[maxn],H[maxn],c[maxn];
bool vis[maxn];
struct Edge{
    int next,to;
}E[maxn<<1];
inline void add(int a,int b){
    E[++cnt]=(Edge){H[a],b};
    H[a]=cnt;
}
void dfs(int x,int fa){
    vis[x]=true;
    ans[++len]=x;
    c[x]^=1;
    for(int i=H[x];i;i=E[i].next){
        int y=E[i].to;
        if(vis[y]) continue;
        dfs(y,x);
        ans[++len]=x;
        c[x]^=1;
    }
    if(c[x]) ans[++len]=fa,ans[++len]=x,c[x]^=1,c[fa]^=1;
}
int main(){
    n=read(),m=read();
    for(int i=1;i<=m;i++){
        int x=read(),y=read();
        add(x,y),add(y,x);
    }
    for(int i=1;i<=n;i++)
      c[i]=read();
    dfs(1,0);
    for(int i=1;i<=n;i++)
      if(c[i] && !vis[i]){
          printf("-1\n");
          return 0;
      }
    if(len>1 && ans[len-1]==0)
      len-=3;
    printf("%d\n",len);
    for(int i=1;i<=len;i++)
      printf("%d ",ans[i]);
    putchar('\n');
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int sum=0;
    char c=getchar();
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)){
        sum=sum*10+(c^48);
        c=getchar();
    }
    return sum;
}
int const maxn=1e5+5;
int n,m,cnt,len,ans[maxn],H[maxn],c[maxn];
bool vis[maxn];
struct Edge{
    int next,to;
}E[maxn<<1];
inline void add(int a,int b){
    E[++cnt]=(Edge){H[a],b};
    H[a]=cnt;
}
void dfs(int x,int fa){
    vis[x]=true;
    ans[++len]=x;
    c[x]^=1;
    for(int i=H[x];i;i=E[i].next){
        int y=E[i].to;
        if(vis[y]) continue;
        dfs(y,x);
        ans[++len]=x;
        c[x]^=1;
    }
    if(c[x]) ans[++len]=fa,ans[++len]=x,c[x]^=1,c[fa]^=1;
}
int main(){
    n=read(),m=read();
    for(int i=1;i<=m;i++){
        int x=read(),y=read();
        add(x,y),add(y,x);
    }
    int start=1;
    for(int i=1;i<=n;i++){
        c[i]=read();
        if(c[i]) start=i;
    }
    dfs(start,0);
    for(int i=1;i<=n;i++)
      if(c[i] && !vis[i]){
          printf("-1\n");
          return 0;
      }
    if(len>1 && ans[len-1]==0)
      len-=3;
    printf("%d\n",len);
    for(int i=1;i<=len;i++)
      printf("%d ",ans[i]);
    putchar('\n');
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define maxn 100000
using namespace std;
int n,m;
vector<int>E[maxn+5];
vector<int>ans;
bool vis[maxn+5];
int tim[maxn+5];
int cnt[maxn+5];
void dfs(int x,int fa){
	ans.push_back(x);
	vis[x]=1;
	cnt[x]^=1;
	for(int y : E[x]){
		if(y!=fa&&!vis[y]){
			dfs(y,x);
			ans.push_back(x);
			cnt[x]^=1;
		}
	}
	if(fa!=0&&cnt[x]==1){
		ans.push_back(fa);
		ans.push_back(x);
		cnt[fa]^=1;
		cnt[x]^=1;
	}
}
int main(){
	int u,v;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d %d",&u,&v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	for(int i=1;i<=n;i++) scanf("%d",&cnt[i]);
	int st=1;
	for(int i=1;i<=n;i++){
		if(cnt[i]==1) st=i;
	}
	dfs(st,0);
	for(int i=1;i<=n;i++){
		if(!vis[i]&&cnt[i]){
			printf("-1\n");
			return 0;
		}
	}
	int sz=ans.size();
	if(cnt[st]) sz--;
	printf("%d\n",sz);
	for(int i=0;i<sz;i++) printf("%d ",ans[i]);
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define maxn 100000
using namespace std;
int n,m;
vector<int>E[maxn+5];
vector<int>ans;
bool vis[maxn+5];
int tim[maxn+5];
int cnt[maxn+5];
void dfs(int x,int fa){
	ans.push_back(x);
	vis[x]=1;
	cnt[x]^=1;
	for(int y : E[x]){
		if(y!=fa&&!vis[y]){
			dfs(y,x);
			ans.push_back(y);
			cnt[y]^=1;
		}
	}
	if(fa!=0&&cnt[x]==1){
		ans.push_back(fa);
		ans.push_back(x);
		cnt[fa]^=1;
		cnt[x]^=1;
	}
}
int main(){
	int u,v;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d %d",&u,&v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	for(int i=1;i<=n;i++) scanf("%d",&tim[i]);
	int st=1;
	for(int i=1;i<=n;i++){
		if(tim[i]==1) st=i;
	}
	dfs(st,0);
	for(int i=1;i<=n;i++){
		if(tim[i]!=cnt[i]){
			printf("-1\n");
			return 0;
		}
	}
	int sz=ans.size();
	printf("%d\n",sz);
	for(int x : ans) printf("%d ",x);
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define maxn 100000
using namespace std;
int n,m;
vector<int>E[maxn+5];
vector<int>ans;
bool vis[maxn+5];
int tim[maxn+5];
int cnt[maxn+5];
void dfs(int x,int fa){
	ans.push_back(x);
	vis[x]=1;
	cnt[x]^=1;
	for(int y : E[x]){
		if(y!=fa&&!vis[y]){
			dfs(y,x);
			ans.push_back(x);
			cnt[x]^=1;
		}
	}
	if(fa!=0&&cnt[x]==1){
		ans.push_back(fa);
		ans.push_back(x);
		cnt[fa]^=1;
		cnt[x]^=1;
	}
}
int main(){
	int u,v;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d %d",&u,&v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	for(int i=1;i<=n;i++) scanf("%d",&cnt[i]);
	int st=1;
	for(int i=1;i<=n;i++){
		if(cnt[i]==1) st=i;
	}
	dfs(st,0);
	for(int i=1;i<=n;i++){
		if(!vis[i]&&cnt[i]){
			printf("-1\n");
			return 0;
		}
	}
	int sz=ans.size();
	printf("%d\n",sz);
	for(int x : ans) printf("%d ",x);
}


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

#define MAX_VETRIX 10001

class Little_Pony_and_Summer_Sun_Celebrationc
{
    private:
        /* data */
        int num_of_vetrix;
        int num_of_edge;
        vector<int> graph[MAX_VETRIX];
        int visited[MAX_VETRIX];
        int parity_of_vetrix[MAX_VETRIX];
        int path[MAX_VETRIX*4];
        int node_in_path;

    public:

        void solve(){

            node_in_path = 0;

            cin>>num_of_vetrix>>num_of_edge;

            int u,v;
            for(int i = 0; i < num_of_edge; i++){
                cin>>u>>v;
                graph[u].push_back(v);
                graph[v].push_back(u);
            }

            int parity, start = -1;
            for(int i = 1; i <= num_of_vetrix; i++){
                cin>>parity;
                parity_of_vetrix[i] = parity;
                visited[i] = 0 ;

                if(start == -1 && parity == 1) start = i;
            }

            dfs(start);

            if(parity_of_vetrix[start]){
                parity_of_vetrix[start] = 0;
                node_in_path--;
            }

            if(check()){
                cout<<node_in_path<<endl;
                for(int i = 0; i < node_in_path; i++){
                    cout<<path[i];

                    if(i != node_in_path - 1) cout<<' ';
                    else cout<<endl;
                }
            }
            else{
                cout<<-1<<endl;
            }

        };

        void dfs(int vetrix){
            visited[vetrix] = 1;
            add_path(vetrix);

            for(int i = 0; i < graph[vetrix].size(); i++){

                if(visited[ graph[vetrix][i] ]) continue;

                dfs(graph[vetrix][i]);

                add_path(vetrix);

                if(parity_of_vetrix[ graph[vetrix][i] ]) {
                    add_path( graph[vetrix][i] );
                    add_path(vetrix);
                }
            }

        };

        void add_path(int vetrix){
            path[node_in_path++] = vetrix;
            parity_of_vetrix[vetrix] ^= 1;
        };

        bool check(){
            for(int i = 1; i <= num_of_vetrix; i++ ) if (parity_of_vetrix[i]) return false;

            return true;
        }

};

int main(int argc, char const *argv[])
{
    Little_Pony_and_Summer_Sun_Celebrationc solution;

    solution.solve();

    return 0;
}


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

#define MAX_VETRIX 10010

class Little_Pony_and_Summer_Sun_Celebrationc
{
    private:
        /* data */
        int num_of_vetrix;
        int num_of_edge;
        vector<int> graph[MAX_VETRIX];
        int visited[MAX_VETRIX];
        int parity_of_vetrix[MAX_VETRIX];
        int path[MAX_VETRIX*4];
        int node_in_path;

    public:

        void solve(){

            node_in_path = 0;

            cin>>num_of_vetrix>>num_of_edge;

            int u,v;
            for(int i = 0; i < num_of_edge; i++){
                cin>>u>>v;
                graph[u].push_back(v);
                graph[v].push_back(u);
            }

            int parity, start = -1;
            for(int i = 1; i <= num_of_vetrix; i++){
                cin>>parity;
                parity_of_vetrix[i] = parity;
                visited[i] = 0 ;

                if(start == -1 && parity == 1) start = i;
            }

            dfs(start);

            if(parity_of_vetrix[start]){
                parity_of_vetrix[start] = 0;
                node_in_path--;
            }

            if(check()){
                cout<<node_in_path<<endl;
                for(int i = 0; i < node_in_path; i++){
                    cout<<path[i];

                    if(i != node_in_path - 1) cout<<' ';
                    else cout<<endl;
                }
            }
            else{
                cout<<-1<<endl;
            }

        };

        void dfs(int vetrix){
            visited[vetrix] = 1;
            add_path(vetrix);

            for(int i = 0; i < graph[vetrix].size(); i++){

                if(visited[ graph[vetrix][i] ]) continue;

                dfs(graph[vetrix][i]);

                add_path(vetrix);

                if(parity_of_vetrix[ graph[vetrix][i] ]) {
                    add_path( graph[vetrix][i] );
                    add_path(vetrix);
                }
            }

        };

        void add_path(int vetrix){
            path[node_in_path++] = vetrix;
            parity_of_vetrix[vetrix] ^= 1;
        };

        bool check(){
            for(int i = 1; i <= num_of_vetrix; i++ ) if (parity_of_vetrix[i]) return false;

            return true;
        }

};

int main(int argc, char const *argv[])
{
    Little_Pony_and_Summer_Sun_Celebrationc solution;

    solution.solve();

    return 0;
}


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

#define MAX_VETRIX 10001

class Little_Pony_and_Summer_Sun_Celebrationc
{
    private:
        /* data */
        int num_of_vetrix;
        int num_of_edge;
        vector<int> graph[MAX_VETRIX];
        int visited[MAX_VETRIX];
        int parity_of_vetrix[MAX_VETRIX];
        int path[MAX_VETRIX*4];
        int node_in_path;

    public:

        void solve(){

            node_in_path = 0;

            cin>>num_of_vetrix>>num_of_edge;

            int u,v;
            for(int i = 0; i < num_of_edge; i++){
                cin>>u>>v;
                graph[u].push_back(v);
                graph[v].push_back(u);
            }

            int parity, start = -1;
            for(int i = 1; i <= num_of_vetrix; i++){
                cin>>parity;
                parity_of_vetrix[i] = parity;
                visited[i] = 0 ;

                if(start == -1 && parity == 1) start = i;
            }

            dfs(start);

            if(parity_of_vetrix[start]){
                parity_of_vetrix[start] = 0;
                node_in_path--;
            }

            if(check()){
                cout<<node_in_path<<endl;
                for(int i = 0; i < node_in_path; i++){
                    cout<<path[i];

                    if(i != node_in_path - 1) cout<<' ';
                    else cout<<endl;
                }
            }
            else{
                cout<<-1<<endl;
            }

        };

        void dfs(int vetrix){
            visited[vetrix] = 1;
            add_path(vetrix);

            for(int i = 0; i < graph[vetrix].size(); i++){

                if(visited[ graph[vetrix][i] ]) continue;

                dfs(graph[vetrix][i]);

                add_path(vetrix);

                if(parity_of_vetrix[ graph[vetrix][i] ]) {
                    add_path( graph[vetrix][i] );
                    add_path(vetrix);
                }
            }

        };

        void add_path(int vetrix){
            path[node_in_path++] = vetrix;
            parity_of_vetrix[vetrix] ^= 1;
        };

        bool check(){
            for(int i = 0; i < num_of_vetrix; i++ ) if (parity_of_vetrix[i]) return false;

            return true;
        }

};

int main(int argc, char const *argv[])
{
    Little_Pony_and_Summer_Sun_Celebrationc solution;

    solution.solve();

    return 0;
}


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

#define MAX_VETRIX 100001

class Little_Pony_and_Summer_Sun_Celebrationc
{
    private:
        /* data */
        int num_of_vetrix;
        int num_of_edge;
        vector<int> graph[MAX_VETRIX];
        int visited[MAX_VETRIX];
        int parity_of_vetrix[MAX_VETRIX];
        int path[MAX_VETRIX*4];
        int node_in_path;

    public:

        void solve(){

            node_in_path = 0;

            cin>>num_of_vetrix>>num_of_edge;

            int u,v;
            for(int i = 0; i < num_of_edge; i++){
                cin>>u>>v;
                graph[u].push_back(v);
                graph[v].push_back(u);
            }

            int parity, start = -1;
            for(int i = 1; i <= num_of_vetrix; i++){
                cin>>parity;
                parity_of_vetrix[i] = parity;
                visited[i] = 0 ;

                if(start == -1 && parity == 1) start = i;
            }

            dfs(start);

            if(parity_of_vetrix[start]){
                parity_of_vetrix[start] = 0;
                node_in_path--;
            }

            if(check()){
                cout<<node_in_path<<endl;
                for(int i = 0; i < node_in_path; i++){
                    cout<<path[i];

                    if(i != node_in_path - 1) cout<<' ';
                    else cout<<endl;
                }
            }
            else{
                cout<<-1<<endl;
            }

        };

        void dfs(int vetrix){
            visited[vetrix] = 1;
            add_path(vetrix);

            for(int i = 0; i < graph[vetrix].size(); i++){

                if(visited[ graph[vetrix][i] ]) continue;

                dfs(graph[vetrix][i]);

                add_path(vetrix);

                if(parity_of_vetrix[ graph[vetrix][i] ]) {
                    add_path( graph[vetrix][i] );
                    add_path(vetrix);
                }
            }

        };

        void add_path(int vetrix){
            path[node_in_path++] = vetrix;
            parity_of_vetrix[vetrix] ^= 1;
        };

        bool check(){
            for(int i = 1; i <= num_of_vetrix; i++ ) if (parity_of_vetrix[i]) return false;

            return true;
        }

};

int main(int argc, char const *argv[])
{
    Little_Pony_and_Summer_Sun_Celebrationc solution;

    solution.solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define SIZE 100010
int Ver[SIZE],Next[SIZE],Head[SIZE];
int tot=0;
int a[SIZE],vis[SIZE];
int n,m;
int cnt=0;
int Ans[SIZE],dep[SIZE],fa[SIZE];
int find(int x){
	return fa[x]==x? x:(fa[x]=find(fa[x]));
}
void Add(int x,int y){
	Ver[++tot]=y;
	Next[tot]=Head[x];
	Head[x]=tot;
}
int check(){
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]==1&&vis[i]%2==0) ans++;
		else if(a[i]==0&&vis[i]%2==1) ans++;
	}
	return ans;
}
void dfs(int x,int fa){
	if(check()==0) return;
	Ans[++cnt]=x;
	vis[x]++;
	if(check()==0) return ;
	if(dep[x]==1&&fa!=0){
		if(check()==0) return;
		if(a[x]%2==0){
			if(check()==0) return;
			if(vis[x]%2==1)dfs(fa,x);
			else{
				if(check()==0) return;
				Ans[++cnt]=fa;
				vis[fa]++;
				return;
			}
		}
		else {
			if(check()==0) return;
			Ans[++cnt]=fa;
			vis[fa]++;
			return ;
		}
	}
	else{
		if(check()==0) return;
		if(a[x]%2==1&&vis[x]%2==0){
			if(check()==0) return;
			if(fa!=0) dfs(fa,x);
			else{
				if(check()==0) return;
				for(int i=Head[x];i;i=Next[i]){
					if(check()==0) return;
					int y=Ver[i];
					if(y==0) continue;
					if(check()==0) return;
					if(a[y]%2==0&&vis[y]%2==0&&vis[2]) continue;
					if(a[y]%2==1&&vis[y]%2==1) continue;
					if(check()==0) return;
					if(a[y]%2==1){
						if(check()==0) return;
						dfs(y,x);
						break;
					}
					if(check()==0) return;
//					Ans[++cnt]=x;
				}
			}
			return;
		}
	}
	for(int i=Head[x];i;i=Next[i]){
		if(check()==0) return;
		int y=Ver[i];
		if(check()==0) return;
		if(y==fa||y==0)continue;
		dfs(y,x);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		if(find(x)==find(y)) continue;
		if(tot/2==n-1) break;
		fa[find(y)]=find(x);
		Add(x,y);Add(y,x);
		dep[x]++;dep[y]++;
	}

	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	dfs(1,0);
//	for(int i=1;i<=n;i++) cout<<vis[i]<<"";
//	cout<<endl;
//	cout<<check()<<"hahahahahahhaahaha"<<endl;
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++) printf("%d ",Ans[i]);
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
const int N=2e5+10;
int n,m,rt,Size,cnt[N],jo[N];
vector<int> ans,G[N];
bool vis[N];

void dfs(int x,int fa)
{
    vis[x]=rt;
    ans.push_back(x); cnt[x]++;
    for(int i=0;i<G[x].size();i++)
	{
        int y=G[x][i];
        if(vis[y]) continue;
        dfs(y,x);
        ans.push_back(x); cnt[x]++;
    }
    if(x!=rt)
        if (cnt[x]%2!=jo[x])
		{
            ans.push_back(fa); cnt[fa]++;
            ans.push_back(x); cnt[x]++;
        }
}

int main()
{
	int x,y;
    cin>>n>>m;
    for (int i=1;i<=m;i++)
	{
        cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    for (int i=1;i<=n;i++)cin>>jo[i];

    rt=1;
	for (int i=1;i<=n;i++) if (jo[i]) rt=i;
    dfs(rt,0);

    int Size=ans.size();
    if (cnt[rt]%2!=jo[rt]) cnt[rt]--,Size--;

    for (int i=1;i<=n;i++)
        if (cnt[i]%2!=jo[i]) {cout<<"-1"<<endl; return 0;}

    cout<<Size<<endl;
    for (int i=0;i<Size;i++) cout<<ans[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define mz(y) memset(y,0,sizeof(y))
#define pb push_back
const int maxn=1000005;
const int maxm=2000005;
struct Edge {int v,next;}e[maxm];
int en,head[maxn];
void add(int x,int y){
e[en].v=y;e[en].next=head[x];head[x]=en++;}
void init(){memset(head,-1,sizeof(head));en=0;}
bool a[maxn];
int d[maxn],n,m,st,ed,vis[maxn];
vector<int>b;
void dfs(int x){vis[x]=1;b.pb(x);
for(int i=head[x];i!=-1;i=e[i].next){
if (!vis[e[i].v]){dfs(e[i].v);b.pb(x);vis[x]++;
if(vis[e[i].v]%2!=a[e[i].v]){
vis[e[i].v]++;vis[x]++;b.pb(e[i].v);b.pb(x);}}}
return;}
int farm(){int i,st=-1;
for(i=1;i<=n;i++){if(a[i]==1){st=i;break;}}
if(st==-1)return 0;mz(vis);b.clear();dfs(st);
if(vis[st]%2!=a[st]){
vis[st]--;b.erase(b.begin());}int maxi=b.size();
for(i=1;i<=n;i++)if(vis[i]%2!=a[i])return -1;
return b.size();}
int main(){
int i,j,x,y;init();
scanf("%d%d",&n,&m);mz(d);
for(i=0;i<m;i++){scanf("%d%d",&x,&y);
add(x,y);add(y,x);d[x]++;d[y]++;}
for(i=1;i<=n;i++)scanf("%d",&a[i]);
int ans=farm();printf("%d\n",ans);
if(ans!=-1){int maxi=b.size();
if(maxi>0)printf("%d",b[0]);
for(i=1;i<maxi;i++){printf(" %d",b[i]);}
puts("");}return 0;}


#include<bits/stdc++.h>
using namespace std;
int n,m;
const int N=100100;
int b[N];
struct by
{
	int to,nxt;
}e[2*N];
int head[N];
int tot=0;
int stack[N];
int ans=0;
void add(int x,int y)
{
	tot++;
	e[tot].to=y;
	e[tot].nxt=head[x];
	head[x]=tot;
}
bool vis[N];
void dfs(int x,int fa)
{
	vis[x]=1; stack[++ans]=x; b[x]^=1;
	for(int i=head[x];i;i=e[i].nxt)
	if(!vis[e[i].to])
	  dfs(e[i].to,x),stack[++ans]=x,b[x]^=1;
	if(b[x]) {stack[++ans]=fa; b[fa]^=1; stack[++ans]=x; b[x]^=1; }
}
int main()
{
	cin>>n>>m;
	int u,v;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	int st=0;
	for(int i=1;i<=n;i++)  {scanf("%d",&b[i]);if(b[i])st=i;}
    if(st)  {dfs(st,-1);for(int i=1;i<=n;i++)  if(!vis[i] && b[i]) {printf("-1\n");return 0;}}
    if(ans>1 && stack[ans-1]==-1)  ans-=3;//删除一次震荡和回溯
	printf("%d\n",ans);
	for(int i=1;i<=ans;i++)  printf("%d ",stack[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define SIZE 100010
int Ver[SIZE],Next[SIZE],Head[SIZE];
int tot=0;
int a[SIZE],vis[SIZE];
int n,m;
int cnt=0;
int Ans[SIZE],dep[SIZE],fa[SIZE];
int find(int x){
	return fa[x]==x? x:(fa[x]=find(fa[x]));
}
void Add(int x,int y){
	Ver[++tot]=y;
	Next[tot]=Head[x];
	Head[x]=tot;
}
int check(){
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]==1&&vis[i]%2==0) ans++;
		else if(a[i]==0&&vis[i]%2==1) ans++;
	}
	return ans;
}
void dfs(int x,int fa){
	if(check()==0) return;
	Ans[++cnt]=x;
	vis[x]++;
	if(check()==0) return ;
	if(dep[x]==1&&fa!=0){
		if(check()==0) return;
		if(a[x]%2==0){
			if(check()==0) return;
			if(vis[x]%2==1&&check())dfs(fa,x);
			else{
				if(check()==0) return;
				Ans[++cnt]=fa;
				vis[fa]++;
				return;
			}
		}
		else {
			if(check()==0) return;
			Ans[++cnt]=fa;
			vis[fa]++;
			return ;
		}
	}
	else{
		if(check()==0) return;
		if(a[x]%2==1&&vis[x]%2==0){
			if(check()==0) return;
			if(fa!=0) dfs(fa,x);
			else{
				if(check()==0) return;
				for(int i=Head[x];i;i=Next[i]){
					if(check()==0) return;
					int y=Ver[i];
					if(y==0) continue;
					if(check()==0) return;
					if(a[y]%2==0&&vis[y]%2==0&&vis[2]) continue;
					if(a[y]%2==1&&vis[y]%2==1) continue;
					if(check()==0) return;
					if(a[y]%2==1){
						if(check()==0) return;
						dfs(y,x);
						break;
					}
					if(check()==0) return;
//					Ans[++cnt]=x;
				}
			}
			return;
		}
	}
	for(int i=Head[x];i;i=Next[i]){
		if(check()==0) return;
		int y=Ver[i];
		if(check()==0) return;
		if(y==fa||y==0)continue;
		dfs(y,x);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		if(find(x)==find(y)) continue;
		if(tot/2==n-1) break;
		fa[find(y)]=find(x);
		Add(x,y);Add(y,x);
		dep[x]++;dep[y]++;
	}
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	dfs(1,0);
//	for(int i=1;i<=n;i++) cout<<vis[i]<<"";
//	cout<<endl;
//	cout<<check()<<"hahahahahahhaahaha"<<endl;
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++) printf("%d ",Ans[i]);
	return 0;
}