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.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            pass System Test!
*/

public class Main {
  private static class Task {
    void solve(FastScanner in, PrintWriter out) throws Exception {
      int N = in.nextInt();
      int[] parent = new int[N];
      for (int i = 0; i < N; i++) {
        parent[i] = in.nextInt() - 1;
      }

      ArrayList<ArrayList<Integer>> G = new ArrayList<>();
      for (int i = 0; i < N; i++) G.add(new ArrayList<>());
      for (int i = 0; i < N; i++) {
        G.get(parent[i]).add(i);
      }

      int[] d = decompose(G);

      for (int i = 0; i < N; i++) {
        G.get(i).add(parent[i]);
      }

      ArrayList<ArrayList<Integer>> cycles = new ArrayList<>();
      boolean[] vis = new boolean[N];
      ArrayDeque<Integer> deque = new ArrayDeque<>();
      for (int i = 0; i < N; i++) {
        if (vis[i]) continue;
        ArrayList<Integer> cycle = new ArrayList<>();
        deque.add(i);
        vis[i] = true;
        cycle.add(i);
        while (!deque.isEmpty()) {
          int v = deque.poll();
          for (int w : G.get(v)) {
            if (vis[w]) continue;
            vis[w] = true;
            deque.add(w);
            if (d[cycle.get(0)] < d[w]) continue;
            if (d[cycle.get(0)] > d[w]) cycle.clear();
            cycle.add(w);
          }
        }
        cycles.add(cycle);
      }

      int single = -1;
      for (ArrayList<Integer> cycle : cycles) if (cycle.size() == 1) single = cycle.get(0);
      if (single == -1) single = cycles.get(0).get(0);

      int cost = 0;
      for (ArrayList<Integer> cycle : cycles) {
        int v = cycle.get(0);
        if (parent[v] != single) cost++;
        parent[v] = single;
      }

      out.println(cost);
      for (int i = 0; i < N; i++) {
        if (i > 0) out.print(" ");
        out.print(parent[i] + 1);
      }

    }

    public int[] decompose(ArrayList<ArrayList<Integer>> G) {
      ArrayList<Integer> vs = new ArrayList<>();
      int V = G.size();
      int[] cmp = new int[V];

      ArrayList<ArrayList<Integer>> rG = new ArrayList<>(V);
      for (int i = 0; i < V; i++) rG.add(new ArrayList<Integer>());
      for (int i = 0; i < V; i++) for (int v : G.get(i)) rG.get(v).add(i);
      boolean[] used = new boolean[V];

      ArrayDeque<Integer> stack = new ArrayDeque<>();
      boolean[] added = new boolean[V];
      for (int i = 0; i < V; i++)
        if (!used[i]) {
          stack.addFirst(i);
          while (!stack.isEmpty()) {
            int v = stack.peekFirst();
            used[v] = true;
            boolean pushed = false;
            for (int j = G.get(v).size() - 1; j >= 0; j--) {
              int u = G.get(v).get(j);
              if (!used[u]) {
                stack.addFirst(u);
                pushed = true;
              }
            }
            if (!pushed) {
              stack.pollFirst();
              if (!added[v]) {
                vs.add(v);
                added[v] = true;
              }
            }
          }
        }

      used = new boolean[V];
      int k = 0;
      Collections.reverse(vs);
      for (int i : vs)
        if (!used[i]) {
          stack.push(i);
          used[i] = true;
          cmp[i] = k;
          while (!stack.isEmpty()) {
            int v = stack.peek();
            boolean pushed = false;
            for (int u : rG.get(v))
              if (!used[u]) {
                used[u] = true;
                cmp[u] = k;
                stack.push(u);
                pushed = true;
              }
            if (!pushed) stack.pop();
          }
          k++;
        }
      return cmp;
    }

  }

  /**
   * ここから下はテンプレートです。
   */
  public static void main(String[] args) throws Exception {
    OutputStream outputStream = System.out;
    FastScanner in = new FastScanner();
    PrintWriter out = new PrintWriter(outputStream);
    Task solver = new Task();
    solver.solve(in, out);
    out.close();
  }
  private static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int bufferLength = 0;

    private boolean hasNextByte() {
      if (ptr < bufferLength) {
        return true;
      } else {
        ptr = 0;
        try {
          bufferLength = in.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (bufferLength <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) return buffer[ptr++];
      else return -1;
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    boolean hasNext() {
      skipUnprintable();
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    double[] nextDoubleArray(int n) {
      double[] array = new double[n];
      for (int i = 0; i < n; i++) {
        array[i] = nextDouble();
      }
      return array;
    }

    double[][] nextDoubleMap(int n, int m) {
      double[][] map = new double[n][];
      for (int i = 0; i < n; i++) {
        map[i] = nextDoubleArray(m);
      }
      return map;
    }

    public int nextInt() {
      return (int) nextLong();
    }

    public int[] nextIntArray(int n) {
      int[] array = new int[n];
      for (int i = 0; i < n; i++) array[i] = nextInt();
      return array;
    }

    public long[] nextLongArray(int n) {
      long[] array = new long[n];
      for (int i = 0; i < n; i++) array[i] = nextLong();
      return array;
    }

    public String[] nextStringArray(int n) {
      String[] array = new String[n];
      for (int i = 0; i < n; i++) array[i] = next();
      return array;
    }

    public char[][] nextCharMap(int n) {
      char[][] array = new char[n][];
      for (int i = 0; i < n; i++) array[i] = next().toCharArray();
      return array;
    }

    public int[][] nextIntMap(int n, int m) {
      int[][] map = new int[n][];
      for (int i = 0; i < n; i++) {
        map[i] = nextIntArray(m);
      }
      return map;
    }
  }
}