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, k, i, j, x, y, z, ma, y2, t, x2, f, ans, a[200002], d[200002];
string s;
struct pos {
  int x, y;
};
pos b[200002];
bool cmp(pos l, pos r) {
  if (l.x == r.x) return l.y > r.y;
  return l.x > r.x;
}
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == -1 || a[i] == 0) f = 1;
  }
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
  }
  if (f == 1)
    cout << 0;
  else if (m == 0)
    cout << -1;
  else
    cout << 1 << endl << 1;
}
