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>
using namespace std;
vector<int> adj[300300];
vector<int> idx[300300];
int n, m;
int col[300300], ind = -1, sm = 0;
int sol[300300];
bool vis[300300];
void dfs(int nd) {
  vis[nd] = true;
  int prev = -1;
  for (int i = 0; i < adj[nd].size(); i++) {
    int ch = adj[nd][i];
    int th = idx[nd][i];
    if (vis[ch]) continue;
    dfs(ch);
    if (col[ch]) {
      if (prev == -1) {
        prev = th;
      } else {
        sol[prev] = 1;
        sol[th] = 1;
      }
    }
  }
  if (prev != -1) {
    sol[prev] = 1;
    col[nd] = 1 - col[nd];
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", col + i);
    if (col[i] == -1) {
      if (ind == -1) {
        ind = i;
      } else {
        col[i] = 0;
      }
    } else {
      sm += col[i];
    }
  }
  if (sm % 2 && ind == -1) {
    cout << -1 << endl;
    return 0;
  }
  if (sm % 2) {
    col[ind] = 1;
  } else {
    col[ind] = 0;
  }
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    idx[a].push_back(i);
    adj[b].push_back(a);
    idx[b].push_back(i);
  }
  dfs(1);
  int sss = 0;
  for (int i = 1; i <= m; i++) {
    if (sol[i]) sss++;
  }
  printf("%d\n", sss);
  for (int i = 1; i <= m; i++) {
    if (sol[i]) {
      printf("%d ", i);
    }
  }
}
