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

import java.io.*;
import java.util.*;

public class Solution {

	private static int n, m;
	private static List< List<Edge> > graph;
	private static int[] color;

	private static int[] parentV;
	private static int[] parentE;
	private static boolean[] usedEdge;

	private static int[] solution;
	private static int solutionSize;

	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer st = new StringTokenizer(reader.readLine());
		n = Integer.parseInt(st.nextToken());
		m = Integer.parseInt(st.nextToken());

		color = new int[n];
		parentV = new int[n];
		parentE = new int[n];
		solution = new int[m];
		graph = new ArrayList<>(n);

		for (int i = 0; i < n; ++i) {
			graph.add(new LinkedList<>());
		}

		st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < n; ++i)
			color[i] = Integer.parseInt(st.nextToken());

		for (int i = 0; i < m; ++i) {
			st = new StringTokenizer(reader.readLine());
			int x = Integer.parseInt(st.nextToken()) - 1;
			int y = Integer.parseInt(st.nextToken()) - 1;

			if (color[x] != 0 && color[y] != 0) {
				System.out.println("1\n" + (i + 1));
				reader.close();
				return;
			}


			graph.get(x).add(new Edge(y, i));
			graph.get(y).add(new Edge(x, i));
		}

		reader.close();


		boolean foundSolution = false;

		/* try to find non-cycle solution */
		Arrays.fill(parentV, -1);
		Arrays.fill(parentE, -1);

		for (int i = 0; i < n; ++i) {
			if (color[i] == 0 || parentV[i] != -1)
				continue;

			int res = dfs1(i, i);

			if (res != -1) {

				System.out.println("Non-cycle solution");

				foundSolution = true;
				solutionSize = 0;
				printSolution(res, i);
				break;
			}
		}

		if (foundSolution)
			return;


		/* try to find solution with cycle */
		Arrays.fill(parentV, -1);
		Arrays.fill(parentE, -1);
		usedEdge = new boolean[m];
		Arrays.fill(usedEdge, false);

		for (int i = 0; i < n; ++i) {
			if (color[i] != 0 || parentV[i] != -1)
				continue;

			int res = dfs2(i, i);

			if (res != -1) {
				foundSolution = true;

				System.out.println("Cycle solution");

				solutionSize = 0;
				solution[solutionSize++] = parentE[i] + 1;
				printSolution(res, i);
				break;
			}
		}

		if (foundSolution)
			return;

		/* try to find one-vertex solution */
		for (int i = 0; i < n; ++i) {
			if ((graph.get(i).size() == 0 && color[i] == 0) || color[i] == -1) {
				foundSolution = true;
				System.out.println(0);
				break;
			}
		}

		if (foundSolution)
			return;

		if (!foundSolution)
			System.out.println(-1);
	}

	private static class Edge {
		public int v;
		public int edgenum;

		public Edge(int a, int b) {
			v = a;
			edgenum = b;
		}
	}

	private static int dfs1(int v, int start) {

		if (v != start && color[v] != 0) {
			return v;
		}

		for (Edge edge: graph.get(v)) {
			if (edge.v == start || parentV[edge.v] != -1)
				continue;

			parentV[edge.v] = v;
			parentE[edge.v] = edge.edgenum;

			int ret = dfs1(edge.v, start);

			if (ret != -1)
				return ret;
		}

		return -1;
	}

	private static int dfs2(int v, int start) {
		for (Edge edge: graph.get(v)) {
			if (usedEdge[edge.edgenum] || color[edge.v] != 0 || parentV[edge.v] != -1)
				continue;

			parentV[edge.v] = v;
			parentE[edge.v] = edge.edgenum;
			usedEdge[edge.edgenum] = true;

			if (edge.v == start)
				return edge.v;

			int ret = dfs2(edge.v, start);

			if (ret != -1)
				return ret;
		}

		return -1;
	}

	private static void printSolution(int v, int u) {
		while (v != u) {
			solution[solutionSize++] = parentE[v] + 1;
			v = parentV[v];
		}

		System.out.println(solutionSize);
		for (int i = 0; i < solutionSize; ++i) {
			System.out.println(solution[i]);
		}
	}
}