3 2
1 0 1
1 2
2 3
 10 10
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
6 7
8 3
6 4
4 2
9 2
5 10
9 8
10 7
5 1
6 2

2
1
2
 0

#include <bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

typedef long long int ll;
typedef unsigned long long int ull;

const ll mod = 1e9+9;

using namespace std;

const int limit =3e5+10;

int n, m, sze;
vector<pair<int, int>> a[limit];
vector<int> ans;
int d[limit], de[limit], t = 0, s = 0;
bool visited[limit];

void dfs(int x,int y){
  visited[x] = 1;
  for(auto e:a[x]){
    if(y == e.first) continue;
    if(visited[e.first]) continue;
    dfs(e.first, x);
    if(d[e.first]){
      d[e.first] ^= 1;
      d[x] ^= 1;
      ans.push_back(e.second);
    }
  }
}

main(int argc, char const *argv[]) {
  //freopen("test.txt","r", stdin);

  cin >> n >> m;
  for(int i = 1; i <= n; i++){
    cin >> d[i];
    if(d[i] ==- 1) t++;
    if(d[i] == 1) s++;
  }
  if(s % 2 == 1 && t == 0){
    cout << "-1" << endl;
    return 0;
  }
  for(int i = 1; i <= n; i++){
    if(d[i] ==- 1){
      d[i] = s % 2;
      s += d[i];
    }
  }
  for(int i = 1; i <= m; i++){
    int x, y;
    cin >> x >> y;
    a[x].push_back({y, i});
    a[y].push_back({x, i});
  }
  sze = ans.size();
  dfs(1, 0);
  sort(ans.begin(), ans.end());
  cout << sze << endl;
  for(int i = 0; i < sze; i++){
    cout << ans[i] << endl;
  }

  return 0;
}
