Problem: A tree is an undirected connected graph without cycles.

Let's consider a rooted undirected tree with n vertices, numbered 1 through n. There are many ways to represent such a tree. One way is to create an array with n integers p1, p2, ..., pn, where pi denotes a parent of vertex i (here, for convenience a root is considered its own parent).

<image> For this rooted tree the array p is [2, 3, 3, 2].

Given a sequence p1, p2, ..., pn, one is able to restore a tree:

  1. There must be exactly one index r that pr = r. A vertex r is a root of the tree. 
  2. For all other n - 1 vertices i, there is an edge between vertex i and vertex pi. 



A sequence p1, p2, ..., pn is called valid if the described procedure generates some (any) rooted tree. For example, for n = 3 sequences (1,2,2), (2,3,1) and (2,1,3) are not valid.

You are given a sequence a1, a2, ..., an, not necessarily valid. Your task is to change the minimum number of elements, in order to get a valid sequence. Print the minimum number of changes and an example of a valid sequence after that number of changes. If there are many valid sequences achievable in the minimum number of changes, print any of them.

Input

The first line of the input contains an integer n (2 ≤ n ≤ 200 000) — the number of vertices in the tree.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ n).

Output

In the first line print the minimum number of elements to change, in order to get a valid sequence.

In the second line, print any valid sequence possible to get from (a1, a2, ..., an) in the minimum number of changes. If there are many such sequences, any of them will be accepted.

Examples

Input

4
2 3 3 4


Output

1
2 3 4 4 


Input

5
3 2 2 5 3


Output

0
3 2 2 5 3 


Input

8
2 3 5 4 1 6 6 7


Output

2
2 3 7 8 1 6 6 7

Note

In the first sample, it's enough to change one element. In the provided output, a sequence represents a tree rooted in a vertex 4 (because p4 = 4), which you can see on the left drawing below. One of other correct solutions would be a sequence 2 3 3 2, representing a tree rooted in vertex 3 (right drawing below). On both drawings, roots are painted red.

<image>

In the second sample, the given sequence is already valid.

Solution (in JAVA):

Solution:
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Set;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class studyDemo
{
    /********************************************** a list of common variables **********************************************/
    private MyScanner scan = new MyScanner();
    private PrintWriter out = new PrintWriter(System.out);
    private final double PI = Math.PI;
    private final int INF = (int)(1e9);
    private final double EPS = 1e-6;
    private final int SIZEN = (int)(1e7);
    private final int MOD = (int)(1e9 + 7);
    private final long MODH = 10000000007L, BASE = 10007;
    private final int[] DX = {0, 1, 0, -1}, DY = {-1, 0, 1, 0};


    public void foo1()
    {
        int n = scan.nextInt();
        int a = 0, b = 0, c = 0;
        int a1 = 0, b1 = 0, c1 = 0;
        for(int i = 0;i < n;++i) {
            int x = scan.nextInt();
            if (x == 0) {
                a1 = Math.min(a, Math.min(b, c)) + 1;
                b1 = 1000;
                c1 = 1000;
            } else if (x == 1) {
                a1 = Math.min(a, Math.min(b, c)) + 1;
                b1 = Math.min(a, c);
                c1 = 1000;
            } else if (x == 2) {
                a1 = Math.min(a, Math.min(b, c)) + 1;
                b1 = 1000;
                c1 = Math.min(a, b);
            } else {
                a1 = Math.min(a, Math.min(b, c)) + 1;
                b1 = Math.min(a, c);
                c1 = Math.min(a, b);
            }
            a = a1;
            b = b1;
            c = c1;
        }
        out.println(Math.min(a, Math.min(b, c)));
    }

    public void foo() {
        int n = scan.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[n + 1];
        for (int i = 1;i <= n;++i) {
            a[i] = scan.nextInt();
            b[i] = a[i];
        }
        boolean[] vis = new boolean[n + 1];
        boolean[] vis2 = new boolean[n + 1];
        int root = -1;
        for(int i = 1;i <= n;++i) {
            if (i == a[i]) {
                root = i;
                vis[i] = true;
                break;
            }
        }
        int ans = 0;
        for (int i = 1;i <= n;++i) {
            if (vis[i]) {
                continue;
            }
            if (i == a[i]) {
                if (i != root) {
                    b[i] = root;
                    ++ans;
                }
                vis[i] = true;
            } else {
                int u = i;
                while (!vis[u] && !vis2[u]) {
                    vis2[u] = true;
                    u = a[u];
                }
                if (vis2[u]) {
                    if (root == -1) {
                        root = u;
                    }
                    b[u] = root;
                    ++ans;
                }
                u = i;
                while (!vis[u]) {
                    vis[u] = true;
                    vis2[u] = false;
                    u = a[u];
                }
            }
        }
        out.println(ans);
        for(int i = 1;i <= n;++i) {
            out.print(b[i] + " ");
        }
        out.println();
    }

    public static void main(String[] args)
    {
        studyDemo m = new studyDemo();
        m.foo();
        m.out.close();
    }

    /********************************************** a list of common algorithms **********************************************/
    /**
     * 1---Get greatest common divisor
     * @param a :	first number
     * @param b :	second number
     * @return		greatest common divisor
     */
    public long gcd(long a, long b)
    {
        return 0 == b ? a : gcd(b, a % b);
    }

    /**
     * 2---Get the distance from a point to a line
     * @param x1	the x coordinate of one endpoint of the line
     * @param y1	the y coordinate of one endpoint of the line
     * @param x2	the x coordinate of the other endpoint of the line
     * @param y2	the y coordinate of the other endpoint of the line
     * @param x		the x coordinate of the point
     * @param y		the x coordinate of the point
     * @return		the distance from a point to a line
     */
    public double getDist(long x1, long y1, long x2, long y2, long x, long y)
    {
        long a = y2 - y1;
        long b = x1 - x2;
        long c = y1 * (x2 - x1) - x1 * (y2 - y1);
        return Math.abs(a * x + b * y + c) / Math.sqrt(a * a + b * b);
    }

    /**
     * 3---Get the distance from one point to a segment (not a line)
     * @param x1	the x coordinate of one endpoint of the segment
     * @param y1	the y coordinate of one endpoint of the segment
     * @param x2	the x coordinate of the other endpoint of the segment
     * @param y2	the y coordinate of the other endpoint of the segment
     * @param x		the x coordinate of the point
     * @param y		the y coordinate of the point
     * @return		the distance from one point to a segment (not a line)
     */
    public double ptToSeg(long x1, long y1, long x2, long y2, long x, long y)
    {
        double cross = (x2 - x1) * (x - x1) + (y2 - y1) * (y - y1);
        if(cross <= 0)
        {
            return (x - x1) * (x - x1) + (y - y1) * (y - y1);
        }
        double d = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
        if(cross >= d)
        {
            return (x - x2) * (x - x2) + (y - y2) * (y - y2);
        }
        double r = cross / d;
        double px = x1 + (x2 - x1) * r;
        double py = y1 + (y2 - y1) * r;
        return (x - px) * (x - px) + (y - py) * (y - py);
    }

    /**
     * 4---KMP match, i.e. kmpMatch("abcd", "bcd") = 1, kmpMatch("abcd", "bfcd") = -1.
     * @param t:	String to match.
     * @param p:	String to be matched.
     * @return		if can match, first index; otherwise -1.
     */
    public int kmpMatch(char[] t, char[] p)
    {
        int n = t.length;
        int m = p.length;
        int[] next = new int[m + 1];
        next[0] = -1;
        int j = -1;
        for(int i = 1;i < m;++i)
        {
            while(j >= 0 && p[i] != p[j + 1])
            {
                j = next[j];
            }
            if(p[i] == p[j + 1])
            {
                ++j;
            }
            next[i] = j;
        }
        j = -1;
        for(int i = 0;i < n;++i)
        {
            while(j >= 0 && t[i] != p[j + 1])
            {
                j = next[j];
            }
            if(t[i] == p[j + 1])
            {
                ++j;
            }
            if(j == m - 1)
            {
                return i - m + 1;
            }
        }
        return -1;
    }

    /**
     * 5---Get the hash code of a String
     * @param	s:	input string
     * @return	hash code
     */
    public long hash(String s)
    {
        long key = 0, t = 1;
        for(int i = 0;i < s.length();++i)
        {
            key = (key + s.charAt(i) * t) % MODH;
            t = t * BASE % MODH;
        }
        return key;
    }

    /**
     * 6---Get x ^ n % MOD quickly.
     * @param	x:	base
     * @param 	n:	times
     * @return	x ^ n % MOD
     */
    public long quickMod(long x, long n)
    {
        long ans = 1;
        while(n > 0)
        {
            if(1 == n % 2)
            {
                ans = ans * x % MOD;
            }
            x = x * x % MOD;
            n >>= 1;
        }
        return ans;
    }

    /**
     * 7---judge if a point is located inside a polygon
     * @param x0	the x coordinate of the point
     * @param y0	the y coordinate of the point
     * @return true if it is inside the polygon, otherwise false
     */
	/*public boolean contains(double x0, double y0)
	{
		int cross = 0;
		for(int i = 0;i < n;++i)
		{
			double s = x[i + 1] == x[i] ? 100000000 : (double)(y[i + 1] - y[i]) / (x[i + 1] - x[i]);
			boolean b1 = x[i] <= x0 && x0 < x[i + 1];
			boolean b2 = x[i + 1] <= x0 && x0 < x[i];
			boolean b3 = y0 < s * (x0 - x[i]) + y[i];
			if((b1 || b2) && b3) ++cross;
		}
		return cross % 2 != 0;
	}*/

    /**
     * 8---judge if a point is located on the segment
     * @param	x1	the x coordinate of one point of the segment
     * @param	y1	the y coordinate of one point of the segment
     * @param 	x2	the x coordinate of another point of the segment
     * @param 	y2	the y coordinate of another point of the segment
     * @param	x	the x coordinate of the point
     * @param 	y	the y coordinate of the point
     * @return	true if it is located on the segment, otherwise false
     */
    public boolean isOnSeg(long x1, long y1, long x2, long y2, long x, long y)
    {
        return (x - x1) * (y2 - y1) == (x2 - x1) * (y - y1) &&
                x >= Math.min(x1, x2) && x <= Math.max(x1, x2) &&
                y >= Math.min(y1, y2) && y <= Math.max(y1, y2);
    }

    /**
     * 9---get the cross product
     * @param 	p1	point A
     * @param 	p2	point B
     * @param 	p	point O
     * @return	cross product of OA x OB
     */
	/*public long cross(Point p1, Point p2, Point p)
	{
		return (long)(p1.x - p.x) * (p2.y - p.y) - (long)(p2.x - p.x) * (p1.y - p.y);
	}*/

    /**
     * 10---implement topsort and tell if it is possible
     * @return true if it is possible to implement topsort, otherwise false
     */
	/*public boolean topsort()
	{
		Queue<Integer> q = new LinkedList<Integer>();
		StringBuilder ans = new StringBuilder();
		int[] in = new int[26];
		for(int i = 0;i < 26;++i)
		{
			if(0 == in[i]) 
			{
				ans.append((char)('a' + i));
				q.add(i);
			}
		}
		while(!q.isEmpty())
		{
			int u = q.poll();
			for(int i = 0;i < 26;++i)
			{
				if(map[u][i])
				{
					--in[i];
					if(0 == in[i])
					{
						ans.append((char)('a' + i));
						q.add(i);
					}
				}
			}
		}
		return 26 == ans.length();
	}*/

    class MyScanner
    {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        BufferedInputStream bis = new BufferedInputStream(System.in);

        public int read()
        {
            if (-1 == numChars)
            {
                throw new InputMismatchException();
            }
            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = bis.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do
            {
                if (c < '0' || c > '9')
                {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do
            {
                if (c < '0' || c > '9')
                {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.')
            {
                if (c == 'e' || c == 'E')
                {
                    return res * Math.pow(10, nextInt());
                }
                if (c < '0' || c > '9')
                {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c & 15;
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                    {
                        return res * Math.pow(10, nextInt());
                    }
                    if (c < '0' || c > '9')
                    {
                        throw new InputMismatchException();
                    }
                    m /= 10;
                    res += (c & 15) * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String next()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c)
        {
            return ' ' == c || '\n' == c || '\r' == c || '\t' == c || -1 == c;
        }
    }
}