#include <bits/stdc++.h>   using namespace std;   const int MX_N = 3e5 + 5;   const int MX_M = 3e5 + 5;   int N, M, D[MX_N];   vector<pair<int, int>> al[MX_N];   int vis[MX_N], sumD;   vector<int> edges;   void dfs(int u, int p = 0, int pe = 0) {     vis[u] = 1;     for (auto v : al[u])       if (!vis[v.first]) {         dfs(v.first, u, v.second);       }     if (D[u]) edges.push_back(pe), D[p] ^= 1;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> N >> M;     for (int i = (1); i <= (N); ++i) {       cin >> D[i];       if (D[i] >= 0) sumD += D[i];     }     for (int i = (1); i <= (M); ++i) {       int U, V;       cin >> U >> V;       al[U].emplace_back(V, i);       al[V].emplace_back(U, i);     }     for (int i = (1); i <= (N); ++i)       if (D[i] == -1) {         if (sumD & 1)           D[i] = 1, ++sumD;         else           D[i] = 0;       }     if (sumD & 1)       cout << -1;     else {       dfs(1);       cout << ((int)(edges).size()) <<   n ;       sort(edges.begin(), edges.end());       for (int& e : edges) cout << e <<    ;     }   }   