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 MX = 300010;
vector<int> vec[MX];
int d[MX];
bool visited[MX];
vector<pair<int, int> > edges, selected;
void dfs(int v) {
  visited[v] = true;
  for (auto i = vec[v].begin(); i != vec[v].end(); ++i) {
    if (!visited[*i]) {
      dfs(*i);
      if (d[*i] == 1) {
        d[*i] ^= 1;
        selected.push_back(make_pair(v, *i));
      }
    }
  }
}
void solve() {
  int n, m, a, b, sum = 0, cnt = 0;
  cin >> n >> m;
  int start1 = 1;
  memset(visited, false, sizeof(visited));
  for (long long i = 1; i < n + 1; ++i) {
    cin >> d[i];
    if (d[i] >= 0) {
      sum += d[i];
      start1 = i;
    }
  }
  if (sum % 2 == 0) {
    for (long long i = 1; i < n + 1; ++i) {
      if (d[i] == -1) {
        d[i] = 0;
      }
    }
  } else {
    int flag = 0;
    for (long long i = 1; i < n + 1; ++i) {
      if (d[i] == -1 && !flag) {
        d[i] = 1;
      }
      if (d[i] == -1 && flag) {
        d[i] = 0;
      }
    }
  }
  for (long long i = 0; i < m; ++i) {
    cin >> a >> b;
    vec[a].push_back(b);
    vec[b].push_back(a);
    edges.push_back(make_pair(a, b));
    edges.push_back(make_pair(b, a));
  }
  for (long long i = 1; i < n + 1; ++i) {
    if (vec[i].size() == 1) {
      start1 = i;
      break;
    }
  }
  dfs(start1);
  int temp = 0, si = selected.size();
  cout << si << "\n";
  for (long long i = 0; i < edges.size(); ++i) {
    if (temp == si) break;
    if (edges[i].first == selected[temp].first &&
        edges[i].second == selected[temp].second) {
      cout << i / 2 + 1 << "\n";
      ++temp;
    }
  }
}
int main() {
  bool testing = false;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (testing) {
    freopen("test.txt", "rt", stdin);
    int start = clock();
    solve();
    int end = clock();
    cout << "time: " << (end - start) / (double)(CLOCKS_PER_SEC)*1000
         << " milliseconds\n";
  } else {
    solve();
  }
}
