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;
int n, m, c[300005], P = -1, cnt, cur[300005];
vector<int> v[300005], ans, e[300005];
bool vis[300005];
inline void dfs(int x, int p, int from) {
  vis[x] = true;
  for (int i = 0; i < v[x].size(); i++) {
    int tx = v[x][i];
    if (vis[tx]) continue;
    dfs(tx, x, e[x][i]);
  }
  if (from == -1) return;
  if (cur[x] != c[x]) {
    cur[x] ^= 1;
    cur[p] ^= 1;
    ans.push_back(from);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    if (c[i] == -1) P = i;
    if (c[i] == 1) cnt++;
    cur[i] = 0;
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
    e[x].push_back(i);
    e[y].push_back(i);
  }
  if (cnt % 2 == 1 && P == -1) {
    puts("-1");
    return 0;
  }
  if (cnt % 2 == 1) {
    c[P] = 1;
    for (int i = 1; i <= n; i++)
      if (c[i] == -1 && i != P) c[i] = 0;
  }
  if (cnt == 0) {
    puts("0");
    return 0;
  }
  int bg = 1;
  for (int i = 1; i <= n; i++)
    if (c[i] == 1) bg = i;
  dfs(bg, -1, -1);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  return 0;
}
