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;
const int N = 3e5;
vector<pair<int, int> > g[N + 100];
vector<int> ans;
int d[N + 100], vis[N + 100];
int dfs(int u) {
  vis[u] = 1;
  int now = 0;
  for (auto it : g[u]) {
    if (!vis[it.first]) {
      int f = dfs(it.first);
      if (f) ans.push_back(it.second);
      now = (now + f) % 2;
    }
  }
  if (now == d[u])
    return 0;
  else
    return 1;
}
int main() {
  int n, m, sum = 0, cnt = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", d + i);
    if (d[i] == -1)
      cnt++;
    else {
      sum = (sum + d[i]) % 2;
    }
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(make_pair(v, i));
    g[v].push_back(make_pair(u, i));
  }
  if (sum % 2 && !cnt) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (d[i] == -1) {
      if (cnt == 1) {
        if (sum == 0)
          d[i] = 0;
        else
          d[i] = 1;
      } else
        d[i] = 0;
      cnt--;
    }
  }
  dfs(1);
  printf("%d\n", (int)ans.size());
  for (auto it : ans) {
    printf("%d ", it);
  }
}
