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<vector<int> > way;
vector<vector<pair<int, int> > > sol;
bool vis[1000000];
int col[1000000];
int cnt, pos = 0;
vector<int> ans;
void build(int now) {
  vis[now] = 1;
  for (int i = 0; i < (int)way[now].size(); i++)
    if (!vis[way[now][i]]) {
      sol[now][i].second = 1;
      build(way[now][i]);
    }
}
int dfs(int now, int prd) {
  int targ = (col[now] == 1);
  for (int i = 0; i < (int)way[now].size(); i++)
    if (sol[now][i].second && way[now][i] != prd) {
      int x = dfs(way[now][i], now);
      if (x % 2 == 0 && (cnt - x) % 2 == 0) sol[now][i].second = 0;
      targ += x;
    }
  return targ;
}
int main() {
  (("" != "") ? (freopen(""
                         ".in",
                         "r", stdin),
                 freopen(""
                         ".out",
                         "w", stdout))
              : (0));
  int n, m;
  cin >> n >> m;
  way.resize(n + 1);
  sol.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> col[i];
    cnt += (col[i] == 1);
    if (col[i] == -1) pos = i;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    way[a].push_back(b);
    way[b].push_back(a);
    sol[a].push_back({i, 0});
    sol[b].push_back({i, 0});
  }
  build(1);
  if (cnt % 2 == 1) {
    if (pos == 0) return cout << -1, 0;
    col[pos] = 1;
    cnt++;
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++)
    for (auto j : sol[i])
      if (j.second) ans.push_back(j.first + 1);
  cout << ans.size() << '\n';
  for (auto i : ans) cout << i << ' ';
}
