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 sun.reflect.generics.tree.Tree;

import javax.swing.event.TreeSelectionEvent;
import javax.swing.plaf.synth.SynthTextAreaUI;
import java.io.*;
import java.net.Inet4Address;
import java.text.DecimalFormat;
import java.util.*;
import java.awt.Point;

public class Newbie {

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        solver s = new solver();
        int t = 1;
        while (t > 0) {
            s.sol();
            t--;
        }
        out.close();
    }
           /* static class descend implements Comparator<pair1> {
                public int compare(pair1 o1, pair1 o2) {
                    if (o1.pop != o2.pop)
                        return (int) (o1.pop - o2.pop);
                    else
                        return o1.in - o2.in;
                }
            }*/

    static class InputReader {
        public BufferedReader br;
        public StringTokenizer token;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream), 32768);
            token = null;
        }

        public String sn() {
            while (token == null || !token.hasMoreTokens()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return token.nextToken();
        }

        public int ni() {
            return Integer.parseInt(sn());
        }

        public String snl() throws IOException {
            return br.readLine();
        }

        public long nlo() {
            return Long.parseLong(sn());
        }

        public double nd() {
            return Double.parseDouble(sn());
        }

        public int[] na(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.ni();
            return a;
        }

        public long[] nal(int n) {
            long a[] = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.nlo();
            return a;
        }
    }

    static class ascend implements Comparator<pair> {
        public int compare(pair o1, pair o2) {
            return o2.b - o1.b;
        }
    }

    static class extra {

        static boolean v[] = new boolean[100001];
        static List<Integer> l = new ArrayList<>();
        static int t;

        static void shuffle(int a[]) {
            for (int i = 0; i < a.length; i++) {
                int t = (int) Math.random() * a.length;
                int x = a[t];
                a[t] = a[i];
                a[i] = x;
            }
        }

        static void shufflel(long a[]) {
            for (int i = 0; i < a.length; i++) {
                int t = (int) Math.random() * a.length;
                long x = a[t];
                a[t] = a[i];
                a[i] = x;
            }
        }

        static int gcd(int a, int b) {
            if (b == 0)
                return a;
            else
                return gcd(b, a % b);
        }

        static boolean valid(int i, int j, int r, int c) {
            if (i >= 0 && i < r && j >= 0 && j < c) {
                // System.out.println(i+" /// "+j);
                return true;
            } else {
                //  System.out.println(i+" //f "+j);
                return false;
            }
        }

        static void seive() {
            for (int i = 2; i < 101; i++) {
                if (!v[i]) {
                    t++;
                    l.add(i);
                    for (int j = 2 * i; j < 101; j += i)
                        v[j] = true;
                }
            }
        }

        static int binary(LinkedList<Integer> a, long val, int n) {
            int mid = 0, l = 0, r = n - 1, ans = 0;
            while (l <= r) {
                mid = (l + r) >> 1;
                if (a.get(mid) == val) {
                    r = mid - 1;
                    ans = mid;
                } else if (a.get(mid) > val)
                    r = mid - 1;
                else {
                    l = mid + 1;
                    ans = l;
                }
            }
            return (ans + 1);
        }

        static long fastexpo(long x, long y) {
            long res = 1;
            while (y > 0) {
                if ((y & 1) == 1) {
                    res *= x;
                }
                y = y >> 1;
                x = x * x;
            }
            return res;
        }

        static long lfastexpo(long x, long y, long p) {
            long res = 1;
            x = x % p;
            while (y > 0) {
                if ((y & 1) == 1) {
                    res = (res * x) % p;
                }
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

               /* void dijsktra(int s, List<pair> l[], int n) {
                    PriorityQueue<pair> pq = new PriorityQueue<>(new ascend());
                    int dist[] = new int[100005];
                    boolean v[] = new boolean[100005];
                    for (int i = 1; i <= n; i++)
                        dist[i] = 1000000000;
                    dist[s] = 0;
                    for (int i = 1; i < n; i++) {
                        if (i == s)
                            pq.add(new pair(s, 0));
                        else
                            pq.add(new pair(i, 1000000000));
                    }
                    while (!pq.isEmpty()) {
                        pair node = pq.remove();
                        v[node.a] = true;
                        for (int i = 0; i < l[node.a].size(); i++) {
                            int v1 = l[node.a].get(i).a;
                            int w = l[node.a].get(i).b;
                            if (v[v1])
                                continue;
                            if ((dist[node.a] + w) < dist[v1]) {
                                dist[v1] = dist[node.a] + w;
                                pq.add(new pair(v1, dist[v1]));
                            }
                        }
                    }
                }*/
    }

    static class pair {
        int a;
        int b;

        public pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
    }

    static class pair1 {
        pair p;
        int in;

        public pair1(pair a, int n) {
            this.p = a;
            this.in = n;
        }
    }

    static int inf = 5000013;

    static class solver {
        DecimalFormat df = new DecimalFormat("0.00000000");
        extra e = new extra();
        long mod = (long) (1000000007);

        void sol() throws IOException {
            int n = sc.ni();
            int p[] = new int[n];
            for (int i = 0; i < n; i++)
                p[i] = i;
            List<Integer> cycle = new ArrayList<>();
            int a[] = new int[n];
            int dic[] = new int[200005];
            int size = 0;
            for (int i = 0; i < n; i++) {
                int u = sc.ni();
                a[i] = u;
                u -= 1;
                int p1 = find(i, p);
                int p2 = find(u, p);
                if (i!=u && p1 == p2) {
                    p[u] = u;
                    p[p1] = u;
                    cycle.add(u);
                    size++;
                    dic[u] = 1;
                } else
                    union(i, u, p);
            }
            for (int i = 0; i < n; i++)
                find(i, p);
            //System.out.println(Arrays.toString(p));
            List<Integer> real = new ArrayList<>();
            int dic2[] = new int[n];
            int cnt = 0, ans = 0;
            for (int i = 0; i < n; i++) {
                if (dic[p[i]] != 1) {
                    real.add(p[i]);
                    cnt++;
                }
                if (dic2[p[i]] == 0) {
                    ans++;
                    dic2[p[i]] = 1;
                }
            }
            ans -= 1;
            int prev = -1;
            if (size > 0) {
                for (int i = 1; i < size; i++) {
                    int idx = cycle.get(i);
                    int idx2 = cycle.get(i - 1);
                    a[idx2] = idx + 1;
                }
                if (cnt == 0) {
                    int idx = cycle.get(size - 1);
                    a[idx] = idx + 1;
                    ans++;
                } else
                    prev = cycle.get(size - 1);
            }
            if (prev != -1 || cnt > 0) {
                for (int i = 0; i < cnt; i++) {
                    if (prev == -1) {
                        prev = real.get(i);
                    } else {
                        int curr = real.get(i);
                        a[prev] = curr + 1;
                        prev = curr;
                    }
                }
                a[prev] = prev + 1;
            }
            out.println(ans);
            for (int i = 0; i < n; i++)
                out.print(a[i] + " ");
            out.println();
        }

        int find(int x, int p[]) {
            if (p[x] == x)
                return x;
            p[x] = find(p[x], p);
            return p[x];
        }

        void union(int x, int y, int p[]) {
            int p1 = find(x, p);
            int p2 = find(y, p);
            p[p1] = p2;
        }
    }
}