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 maxn = 300005;
int n, m, a[maxn], u, v, tot, c;
bool vis[maxn];
vector<pair<int, int> > G[maxn];
vector<int> V;
void dfs(int u) {
  vis[u] = 1;
  for (auto p : G[u]) {
    int v = p.first;
    if (vis[v]) continue;
    if (a[u]) {
      a[u] = 0;
      a[v] = a[v] ? 0 : 1;
      V.push_back(p.second);
    }
    dfs(v);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] == -1)
      ++c;
    else
      tot += a[i];
  }
  if (tot % 2 && !c) return 0 * puts("-1");
  for (int i = 1; i <= n; ++i)
    if (a[i] == -1) {
      a[i] = tot % 2;
      tot += a[i];
    }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &u, &v);
    G[u].push_back(pair<int, int>(v, i + 1));
    G[v].push_back(pair<int, int>(u, i + 1));
  }
  dfs(1);
  printf("%d\n", V.size());
  for (int i = 0; i < (int)V.size(); ++i) printf("%d\n", V[i]);
  return 0;
}
