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;
using unum = uint64_t;
using num = int64_t;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& t) {
  return os << '[' << t.first << ',' << t.second << ']';
}
constexpr uint64_t print_limit = 32;
template <typename It>
void print(ostream& os, It begin, It end, uint64_t len) {
  uint64_t count = 0;
  os << "{";
  while (begin != end && count < print_limit) {
    os << "(" << *begin << ")";
    count++;
    begin++;
  }
  if (begin != end) os << "... " << len << " total";
  os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& t) {
  print(os, t.begin(), t.end(), t.size());
  return os;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const map<T1, T2>& t) {
  print(os, t.begin(), t.end(), t.size());
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& t) {
  print(os, t.begin(), t.end(), t.size());
  return os;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const unordered_map<T1, T2>& t) {
  print(os, t.begin(), t.end(), t.size());
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& t) {
  print(os, t.begin(), t.end(), t.size());
  return os;
}
template <typename T>
T read() {
  T e;
  cin >> e;
  return e;
}
template <typename T>
vector<T> readv(unum n) {
  vector<T> v;
  for (unum i = 0; i < n; i++) v.push_back(read<T>());
  return v;
}
template <typename T>
void print(const T& t) {
  cout << t << " ";
}
void println() { cout << '\n'; }
template <typename T>
void println(const T& t) {
  print(t);
  println();
}
template <typename T>
struct identity {
  const T& operator()(const T& t) const { return t; }
};
template <typename T, typename F = identity<typename T::value_type>>
void printv(const T& t, F f = F()) {
  for (const auto& e : t) print(f(e));
  println();
}
set<unum> result;
vector<num> sign;
vector<vector<pair<unum, unum>>> g;
vector<unum> vis;
bool dfs(unum a) {
  vis[a] = true;
  bool open_edge = (sign[a] == 1);
  for (const auto pb : g[a]) {
    if (!vis[pb.first]) {
      const bool child_open_edge = dfs(pb.first);
      if (child_open_edge) result.insert(pb.second);
      open_edge ^= child_open_edge;
    }
  }
  return open_edge;
}
void go() {
  g.resize(read<unum>());
  vis.resize(g.size());
  const auto m = read<unum>();
  sign = readv<num>(g.size());
  {
    bool neg_required = false;
    for (const auto e : sign)
      if (e == 1) neg_required = !neg_required;
    if (neg_required) {
      bool neg_updated = false;
      for (auto& e : sign)
        if (e == -1) {
          e = 1;
          neg_updated = true;
        }
      if (!neg_updated) {
        println("-1");
        return;
      }
    }
  }
  for (unum i = 0; i < m; i++) {
    auto a = read<unum>(), b = read<unum>();
    g[a - 1].emplace_back(b - 1, i + 1);
    g[b - 1].emplace_back(a - 1, i + 1);
  }
  dfs(0);
  println(result.size());
  printv(result);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  go();
}
