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;
int n, m, d[300100];
map<pair<int, int>, vector<int> > st;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &d[i]);
  for (int i = 1; i <= n; ++i)
    if (d[i] <= 0) return puts("0"), 0;
  for (int i = 1, u, v; i <= m; ++i)
    scanf("%d%d", &u, &v), st[pair<int, int>(u, v)].push_back(i);
  for (auto s : st)
    if (s.second.size() % 2) {
      printf("%d\n", s.second.size());
      for (auto t : s.second) printf("%d\n", t);
      return 0;
    }
  puts("-1");
}
