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 ara[300005];
vector<int> vt[300005];
pair<int, int> p[300005];
int main() {
  int i, j, k;
  int n, m;
  cin >> n >> m;
  for (i = 0; i < n; ++i) scanf("%d", &ara[i]);
  for (i = 0; i < m; ++i) {
    scanf("%d %d", &p[i].first, &p[i].second);
    vt[p[i].first].push_back(p[i].second);
    vt[p[i].second].push_back(p[i].first);
  }
  for (i = 0; i < n; ++i) {
    if (ara[i] == -1) {
      printf("0\n");
      return 0;
    }
  }
  for (i = 0; i < m; ++i) {
    if (ara[p[i].first - 1] == 1 && ara[p[i].second - 1] == 1) {
      printf("1\n%d\n", i + 1);
      return 0;
    }
  }
  printf("-1\n");
}
