#include <bits/stdc++.h>   using namespace std;   int par[300005];   int vis[300005];   unordered_map<int, int> edge[300005];   int d[300005];   vector<int> ans;   int find(int u) { return par[u] == u ? u : par[u] = find(par[u]); }   void join(int u, int v) {     u = find(u);     v = find(v);     if (u > v) swap(u, v);     par[v] = u;   }   void dfs(int u, int pr) {     if (vis[u]) return;     vis[u] = 1;     for (auto i : edge[u]) {       dfs(i.first, u);     }     if (d[u] == 1) {       ans.push_back(edge[u][pr]);       d[pr]++;       d[pr] %= 2;       return;     }   }   int main() {     ios_base::sync_with_stdio(false);     memset(vis, 0, sizeof vis);     int n, k, u, v;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       edge[i].clear();       par[i] = i;       cin >> d[i];     }     for (int i = 1; i <= k; i++) {       cin >> u >> v;       if (find(u) != find(v)) {         edge[u][v] = i;         edge[v][u] = i;         join(u, v);       }     }     int sum = 0;     int avail = 0;     for (int i = 1; i <= n; i++) {       if (d[i] == -1) {         avail++;       } else         sum += d[i];     }     if (sum % 2 && !avail) {       cout << -1 << endl;       return 0;     }     for (int i = 1; i <= n; i++) {       if (d[i] == -1) {         if (sum % 2 == 1) {           d[i] = 1;           sum++;         } else           d[i] = 0;       }     }     dfs(1, 0);     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++) {       cout << ans[i] <<    ;     }     return 0;   }   