public void solve() throws IOException {
    int n = nextInt();
    int m = nextInt();

    int[] owe = new int[n];
    boolean[][] friendship = new boolean[n][n];

    for (int x = 0; x < n; x++) {
      owe[x] = nextInt();
    }

    for (int x = 0; x < m; x++) {
      int from = nextInt();
      int to = nextInt();
      friendship[from][to] = true;
      friendship[to][from] = true;
    }

    ArrayList<Integer> remain = new ArrayList<Integer>(n);
    for (int x = 0; x < n; x++) {
      remain.add(x);
    }

    while (remain.size() > 0) {
      int start = remain.remove(0);

      HashSet<Integer> visited = new HashSet<Integer>();
      Queue<Integer> active = new LinkedList<Integer>();
      visited.add(start);
      active.add(start);

      long total = 0;
      while (active.size() > 0) {
        Integer node = active.poll();
        remain.remove(new Integer(node));
        total += owe[node];
        for (int x = 0; x < n; x++) {
          if (!visited.contains(x) && friendship[node][x]) {
            visited.add(x);
            active.add(x);
          }
        }
      }
      if (total != 0) {
        System.out.println("IMPOSSIBLE");
        return;
      }
    }
    System.out.println("POSSIBLE");
  }