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 nax = 3e5 + 111;
int n, m;
int a, b;
int d[nax];
vector<pair<int, int>> v[nax];
vector<int> res;
vector<int> push[nax];
bool odw[nax];
int dfs(int u, int p) {
  odw[u] = 1;
  for (auto it : v[u]) {
    if (!odw[it.first]) {
      if (dfs(it.first, u)) {
        res.push_back(it.second);
        if (d[u] >= 0) d[u] ^= 1;
      }
    }
  }
  if (d[u] == 1) return 1;
  return 0;
}
void solve(int u, int p) {
  odw[u] = 1;
  for (auto it : v[u]) {
    if (!odw[it.first]) {
      solve(it.first, u);
      for (auto i : push[it.first]) push[u].push_back(i);
      if ((int)push[it.first].size()) res.push_back(it.second);
    }
  }
  if (d[u] == 1) push[u].push_back(u);
  while ((int)push[u].size() >= 2) {
    push[u].pop_back();
    push[u].pop_back();
  }
}
int main() {
  scanf("%d %d", &n, &m);
  int odd = 0;
  int root = -1;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", d + i);
    odd += (d[i] % 2 == 1);
    if (d[i] == -1) root = i;
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d", &a, &b);
    v[a].push_back(make_pair(b, i));
    v[b].push_back(make_pair(a, i));
  }
  if (root != -1) {
    dfs(root, 0);
    printf("%d\n", (int)res.size());
    for (auto it : res) printf("%d ", it);
    return 0;
  }
  if (odd & 1) {
    printf("-1");
    return 0;
  }
  solve(1, 0);
  printf("%d\n", (int)res.size());
  for (auto it : res) printf("%d ", it);
  return 0;
}
