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 d[MAXN], sumd;
bool vis[MAXN];
vector<pair<int, int> > g[MAXN];
vector<int> ans;
void DFS(int u, int pre, int eid) {
  vis[u] = true;
  for (auto &p : g[u])
    if (!vis[p.first]) DFS(p.first, u, p.second);
  if (d[u] == 1) {
    ans.push_back(eid);
    if (d[pre] != -1 && pre != 0) d[pre] ^= 1;
  }
  return;
}
int main() {
  int n, m, minusid = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &d[i]), sumd += max(d[i], 0),
        minusid = d[i] == -1 ? i : minusid;
  for (int i = 1, x, y; i <= m; ++i)
    scanf("%d%d", &x, &y), g[x].emplace_back(y, i), g[y].emplace_back(x, i);
  if (minusid != 0 || ((sumd & 1) == 0)) {
    vis[0] = true;
    if (minusid == 0) minusid = 1;
    DFS(minusid, 0, 0);
    printf("%d\n", ans.size());
    for (auto &x : ans) printf("%d ", x);
  } else
    printf("-1\n");
  return 0;
}
