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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
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.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.*;


 
 
public class ck {

	private static InputStream stream;
	private static PrintWriter pw;
	
	
	
//	static int a;
//	static int b;
//	static int f = 0;
	static int n;
	static int m;
	static int parent[];

	
//	static int[][] dir = {{1,0},{0,1},{-1,0},{0,-1}};
//	static ArrayList<Integer> ans;

//	static int arr[][];
//	static int arr[];
//	static char[][] arr;
	static int[] visited;
	//static int c;
	static int d[];
//	static int arr[][];
	static ArrayList<Integer> arr[];
	static Stack<Integer> stack;
	static int c;
	

	
	public static void main(String[] args) throws NumberFormatException, IOException{
		//InputReader(System.in);
		//pw = new PrintWriter(System.out);
		
		Scanner in = new Scanner(System.in);
		
		n = in.nextInt();
		in.nextLine();
		int arr[] = new int[n];
		
		int root = -1;
		parent  = new int[n];
		
		for(int i = 0;i<n;i++){
			arr[i] = in.nextInt()-1;
			if(arr[i] == i){
				root = i;
			}
		
			parent[i] = i;
		}
		
		int ans = 0;
		
		for(int i = 0;i<n;i++){
			if(find(i) != find(arr[i])){
				union(i,arr[i]);
			}else{
				if(root==-1){
					root = find(i);
				//	System.out.println(find(i));
				}
					if(arr[i] != root){
						arr[i] = root;
						ans++;
					}
				
			}
		}
		
		
		System.out.println(ans);
		
		for(int i = 0;i<n;i++){
			System.out.print(arr[i]+1 + " ");
		}
		
		
			
}
	
	public static void union(int a,int b){
		a = find(a);
		b = find(b);
		
		parent[a] = b;
		return;
	}
	
	public static int find(int i){
		if(i == parent[i]){
			return i;
		}
		
		parent[i] = find(parent[i]);
		return parent[i];
	}
	
//	public static void dfs(int i){
//		
//		
//		if(visited[i] == 1){
//			return;
//		}
//		
//		visited[i] = 1;
//		con[c].add(i);
//		//System.out.print(i + " ");
//		for(int j = 0;j<arr[i].size();j++){
//			dfs(arr[i].get(j));
//		}
//		
//	}
//	
//	
//	public static void dfss(int i){
//		if(visited[i] == 1){
//			return;
//		}
//		
//		visited[i] = 1;
//		
//		for(int j = 0;j<arr[i].size();j++){
//			dfss(arr[i].get(j));
//		}
//	//	System.out.println(i);
//		stack.push(i);
//	}
//	
//	public static void reverse(){
//		ArrayList[] temp = new ArrayList[n];
//		
//		for(int i = 0;i<n;i++){
//			temp[i] = new ArrayList();
//		}
//		
//		for(int i = 0;i<n;i++){
//			for(int j = 0;j<arr[i].size();j++){
//				temp[arr[i].get(j)].add(i);
//			}
//		}
//		
//		arr = temp;
//		
//	}
//	
//	
	
	
	
	
	
	
	
	
	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}
	
//	public static void bfs(int s){
//		
//	
//		if(visited[s] == 1){
//			return;
//		}
//		c++;
//		visited[s] = 1;
//		Queue<Integer> q=new LinkedList<Integer>();
//    	q.add(s);
//  
//    	while(!q.isEmpty()){
//    		int top=q.poll();
//    		v++;
//    		Iterator<Integer> i= adj[top].listIterator();
//    		while(i.hasNext()){
//    			int n=i.next();
//    			if(visited[n] == 0){
//    				q.add(n);
//    				visited[n]=1;
//    				
//    			}
//    		}
//    	}
//		
//		
//	}
//	
//	
//	
//	public static void dfs(int i,int j){
//		System.out.println(i + " " + j + " " + arr[i][j]);
//		if(i == x2 && j == y2 && arr[i][j] == 'X'){
//			f = 1;
//			return;
//		}else if(i == x2 && j == y2){
//			
//			for(int p = 0;p<4;p++){
//				int t1 = i + dir[p][0];
//				int t2 = j + dir[p][1];
//				
//				i =t1;j =t2;
//				
//				
//				if(i < 0 || i >=n || j < 0 || j >= m){
//					// fooled you/...
//				}else if(arr[t1][t2] == '.'){
//					System.out.println(i + " " + j+ " " + " insisis" + " " + arr[i][j]);	
//					f = 1;
//					return;
//				}
//			}
//			
//			return;
//		}else if(arr[i][j] == 'X' && i != x1 && j != y1){
//			return;
//		}else if(arr[i][j] == 'X' && i == x1 && j == y1){
//			for(int p = 0;p<4;p++){
//				int t1 = i + dir[p][0];
//				int t2 = j + dir[p][1];
//				i =t1;j =t2;
//				if(i < 0 || i >=n || j < 0 || j >= m){
//					// fooled you/...
//				}else if(arr[t1][t2] == '.'){
//					dfs(t1,t2);
//				}
//			}
//			
//		}
//		
//		int t1 = i;
//		int t2 = j;
////		if(t1 == 3 && t2 == 4){
////			System.out.println(i + " " + j + " inside");
////		}
////		
//		for(int k = 0;k<4;k++){
//		
//			i = t1 + dir[k][0];
//			j = t2 + dir[k][1];
//			
//			if(t1 == 0 && t2 == 6){
//				System.out.println(i + " " + j + " inside");
//			}
//			
//			if(i < 0 || i >=n || j < 0 || j >= m){
//				// fooled you/...
//			}else if(arr[i][j] == '.'){
//				arr[t1][t2] = 'X';
//				dfs(i,j);
//			}else if(i == x2 & j == y2 && arr[i][j] == 'X'){
//				dfs(i,j);
//			}
//		}
//		
//		
//		
//		
//	}
	
	
	
	
	public static boolean isPrime(int n) {
		// Corner cases
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
 
		// This is checked so that we can skip 
		// middle five numbers in below loop
		if (n % 2 == 0 || n % 3 == 0)
			return false;
 
		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;
 
		return true;
	}
	
	
	
	public static void Range(int[] numbers, int target) {
	    if (numbers == null)
	        return;

	    int low = 0, high = numbers.length - 1;
	    // get the start index of target number
	    int startIndex = -1;
	    while (low <= high) {
	        int mid = (high - low) / 2 + low;
	        if (numbers[mid] > target) {
	            high = mid - 1;
	        } else if (numbers[mid] == target) {
	            startIndex = mid;
	            high = mid - 1;
	        } else
	            low = mid + 1;
	    }

	    // get the end index of target number
	    int endIndex = -1;
	    low = 0;
	    high = numbers.length - 1;
	    while (low <= high) {
	        int mid = (high - low) / 2 + low;
	        if (numbers[mid] > target) {
	            high = mid - 1;
	        } else if (numbers[mid] == target) {
	            endIndex = mid;
	            low = mid + 1;
	        } else
	            low = mid + 1;
	    }

	    if (startIndex != -1 && endIndex != -1){
	        for(int i=0; i+startIndex<=endIndex;i++){
	            if(i>0)
	                System.out.print(',');
	            System.out.print(i+startIndex);
	        }
	    }
	}
	
	 // union code starts	
	
	 private static void initialize( int Arr[ ],int size[], int N)
	    {
	        for(int i = 0;i<N;i++)
	        {
	        	Arr[ i ] = i ;
	        	size[ i ] = 1;
	        }
	    }
	 
	 private static int root(int Arr[ ],int i)
	    {
	        while(Arr[ i ] != i)           //chase parent of current element until it reaches root
	        {
	            Arr[ i ] = Arr[ Arr[ i ] ] ; 
	            i = Arr[ i ];
	        }
	        return i;
	    }
	 
	 private static void union(int Arr[ ],int size[ ],int A,int B)
	    {
	        int root_A = root(Arr,A);
	        int root_B = root(Arr,B);
	     
	        if(root_A != root_B){
	        	 if(size[root_A] < size[root_B ])
	 	        {
	        		 Arr[ root_A ] = Arr[root_B];
	        		 size[root_B] += size[root_A];	 	
	 	        }
	 	        else
	 	        {   	
	 	        	Arr[ root_B ] = Arr[root_A];
	 	        	size[root_A] += size[root_B];	 	   
	 	        }	
	        }
	    }
	 
	 private static boolean find(int Arr[],int A,int B)
	    {
	        if( root(Arr,A)==root(Arr,B) )       //if A and B have the same root, it means that they are connected.
	        return true;
	        else
	        return false;
	    }
	 
	 
	 // union code ends
	
	
	 
//	 // Segment tree code begins
//	 
//	 
//	 static void build(int node,int start,int end)
//	 {
//	 if(start==end)
//	 tree[node]=a[start];
//	 else
//	 {
//	 int mid=(start+end)/2;
//	 build(2*node,start,mid);
//	 build(2*node+1,mid+1,end);
//	 if(tree[2*node]<tree[2*node+1])
//	 tree[node]=tree[2*node];
//	 else
//	 tree[node]=tree[2*node+1];
//	 }
//	 }
//	 
//	 
//	 static void update(int node,int start,int end,int idx,int val)
//	 {
//	 if(start==end)
//	 {
//	 a[idx]=val;
//	 tree[node]=val;
//	 }
//	 else
//	 {
//	 int mid=(start+end)/2;
//	 if(idx>=start&&idx<=mid)
//	 update(2*node,start,mid,idx,val);
//	 else
//	 update(2*node+1,mid+1,end,idx,val);
//	 if(tree[2*node]<tree[2*node+1])
//	 tree[node]=tree[2*node];
//	 else
//	 tree[node]=tree[2*node+1];
//	 }
//	 }
//	 
//	 static int query(int node,int start,int end,int l,int r)
//	 {
//	 if(l>end||start>r)
//	 return 100005;
//	 if(l<=start&&r>=end)
//	 return tree[node];
//	 int p1,p2;
//	 int mid=(start+end)/2;
//	 p1=query(2*node,start,mid,l,r);
//	 p2=query(2*node+1,mid+1,end,l,r);
//	 if(p1<p2)
//	 return p1;
//	 else
//	 return p2;
//	 }
//	 
//	 
//	 
//}

}

class Node{
	int a;
	int b;
}


class MyComp2 implements Comparator<Node>{
    
	@Override
	public int compare(Node o1, Node o2) {
		if(o1.b>o2.b){
			return 1;
		}else if(o1.b<o2.b){
			return -1;
		}else{
			return 0;
			
			
		}
		
		
	}
}