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 Inf = 1e9 + 7;
namespace myspace {
const int N = 3e5 + 7;
int n, m;
int d[N];
pair<int, int> edge[N];
int deg[N];
int valid[N];
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> d[i];
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    edge[i] = {min(a, b), max(a, b)};
    deg[a]++;
    deg[b]++;
    valid[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int a = edge[i].first;
    int b = edge[i].second;
    if (d[a] > -1 && d[b] > -1) {
    } else if (d[a] > -1 && d[b] == -1) {
      if (deg[a] % 2 != d[a]) {
        deg[a]--;
        deg[b]--;
        valid[i] = 0;
      }
    } else if (d[a] == -1 && d[b] > -1) {
      if (deg[b] % 2 != d[b]) {
        deg[a]--;
        deg[b]--;
        valid[i] = 0;
      }
    } else {
    }
  }
  for (int i = 1; i <= m; i++)
    if (valid[i]) {
      int a = edge[i].first;
      int b = edge[i].second;
      if (d[a] > -1 && d[b] > -1) {
        if (deg[a] % 2 != d[a] && deg[b] % 2 != d[b]) {
          deg[a]--;
          deg[b]--;
          valid[i] = 0;
        }
      }
    }
  for (int a = 1; a <= n; a++) {
    if (d[a] > -1 && deg[a] % 2 != d[a]) {
      cout << "-1" << '\n';
      return;
    }
  }
  vector<int> res;
  for (int i = 1; i <= m; i++)
    if (valid[i]) res.push_back(i);
  cout << res.size() << '\n';
  for (int x : res) cout << x << " ";
  cout << '\n';
}
};  // namespace myspace
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(9);
  cout << fixed;
  myspace::solve();
  return 0;
}
