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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
T ext_gcd(T a, T b, T& first, T& second) {
  if (b == 0) {
    first = 1, second = 0;
    return a;
  }
  T d = ext_gcd(b, a % b, second, first);
  second -= first * (a / b);
  return d;
}
template <typename T>
T inverse(T a, T n) {
  T first, second;
  T t = ext_gcd(a, n, first, second);
  if (t != 1) return -1;
  return (first % n + n) % n;
}
template <typename T>
T Q_mul(T a, T b, T Mod) {
  T ret;
  for (ret = 0; b; b >>= 1, a = (a + a) % Mod)
    if (b & 1) ret = (ret + a) % Mod;
  return ret;
}
template <typename T>
T quick_pow_mod(T a, T b, T Mod) {
  T ret;
  for (ret = 1; b; b >>= 1, (a *= a) %= Mod)
    if (b & 1) (ret *= a) %= Mod;
  return ret;
}
template <typename T>
T quick_pow(T a, T b) {
  T ret;
  for (ret = 1; b; b >>= 1, a *= a)
    if (b & 1) ret *= a;
  return ret;
}
double combination(int n, int r) {
  if (r < n - r) return combination(n, n - r);
  double s = 1.0;
  for (int i = 1; i <= int(n - r); ++i) s *= (r + i), s /= i;
  return s;
}
template <typename T>
inline void read(T& v) {
  T ret = 0, sgnv = 1;
  char p;
  while (!isdigit(p = getchar()))
    if (p == '-') sgnv = -1;
  do ret = (ret << 3) + (ret << 1) + p - '0';
  while (isdigit(p = getchar()));
  v = sgnv * ret;
}
struct Edge {
  int v, next;
} edge[200000 + 5];
int cnt, head[200000 + 5], s[200000 + 5], t[200000 + 5], p[200000 + 5];
bool vis[200000 + 5];
inline void addedge(int u, int v) {
  edge[cnt].v = v, edge[cnt].next = head[u], head[u] = cnt++;
}
void dfs(int u, int root) {
  vis[u] = true;
  for (int i = head[u]; ~i; i = edge[i].next)
    if (edge[i].v != root) dfs(edge[i].v, root);
}
int main() {
  int n, u, tot = 0, len = 0;
  read(n), memset(head + 1, -1, sizeof(int) * n);
  for (int i = 1; i <= int(n); ++i) {
    read(u), p[i] = u;
    if (u != i)
      addedge(u, i);
    else
      s[tot++] = i;
  }
  for (int i = 0; i < int(tot); ++i) dfs(s[i], 0);
  for (int i = 1; i <= int(n); ++i)
    if (!vis[i]) {
      u = i;
      while (!vis[u]) vis[u] = true, u = p[u];
      t[len++] = u, dfs(u, u);
    }
  for (int i = 1; i <= int(tot - 1); ++i) p[s[i]] = s[0];
  if (tot)
    for (int i = 0; i < int(len); ++i) p[t[i]] = s[0];
  else {
    p[t[0]] = t[0];
    for (int i = 1; i <= int(len - 1); ++i) p[t[i]] = t[0];
  }
  printf("%d", tot == 0 ? len : tot + len - 1), putchar('\n');
  for (int i = 1; i <= int(n); ++i)
    printf("%d", p[i]), i == n ? putchar('\n') : putchar(' ');
  return 0;
}