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 long long inf = (1ll << 45);
const long long mod = 1e9 + 7;
const int MX = 3e5 + 9;
int n, m, d[MX], x = -1, y, vis[MX], k;
vector<pair<int, int> > v[MX];
vector<int> ans;
void dfs(int x) {
  vis[x] = 1;
  for (auto pp : v[x]) {
    if (vis[pp.first]) continue;
    dfs(pp.first);
    if (d[pp.first]) {
      ans.push_back(pp.second);
      d[x] ^= 1;
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    if (d[i] == 1) k++;
    if (d[i] == -1) {
      x = i;
      d[i] = 0;
    }
  }
  if (k % 2) {
    if (x == -1) {
      puts("-1");
      return 0;
    }
    d[x] = 1;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    v[x].push_back({y, i + 1});
    v[y].push_back({x, i + 1});
  }
  dfs(1);
  cout << ans.size() << endl;
  for (auto pp : ans) cout << pp << " ";
}
