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;
int arr[500500];
int main() {
  cin >> n >> m;
  int f = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] == 0 || arr[i] == -1) f = 1;
  }
  int ff = 0;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    if ((arr[u] == 1 || arr[u] == -1) && (arr[v] == 1 || arr[v] == -1)) ff = i;
  }
  if (ff != 0) {
    cout << 1 << endl;
    cout << ff << endl;
  } else if (f) {
    cout << 0 << endl;
  } else
    cout << -1 << endl;
  return 0;
}
