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;
namespace io {
const int __SIZE = (1 << 21) + 1;
char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1,
                                           __c, qu[55];
int __f, qr, _eof;
inline void flush() { fwrite(obuf, 1, oS - obuf, stdout), oS = obuf; }
inline void gc(char &x) {
  x = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                   (iS == iT ? EOF : *iS++))
                : *iS++);
}
inline void pc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
inline void pstr(const char *s) {
  int __len = strlen(s);
  for (__f = 0; __f < __len; ++__f) pc(s[__f]);
}
inline void gstr(char *s) {
  for (__c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                         (iS == iT ? EOF : *iS++))
                       : *iS++);
       __c < 32 || __c > 126 || __c == ' ';)
    __c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                    : *iS++);
  for (; __c > 31 && __c < 127 && __c != ' ';
       ++s, __c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++))
    *s = __c;
  *s = 0;
}
template <class I>
inline bool gi(I &x) {
  _eof = 0;
  for (__f = 1,
      __c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                        (iS == iT ? EOF : *iS++))
                      : *iS++);
       (__c < '0' || __c > '9') && !_eof;
       __c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                         (iS == iT ? EOF : *iS++))
                       : *iS++)) {
    if (__c == '-') __f = -1;
    _eof |= __c == EOF;
  }
  for (x = 0; __c <= '9' && __c >= '0' && !_eof;
       __c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                         (iS == iT ? EOF : *iS++))
                       : *iS++))
    x = x * 10 + (__c & 15), _eof |= __c == EOF;
  x *= __f;
  return !_eof;
}
template <class I>
inline void gp(I x) {
  if (!x) pc('0');
  if (x < 0) pc('-'), x = -x;
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) pc(qu[qr--]);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io::gc;
using io::gi;
using io::gp;
using io::gstr;
using io::pc;
using io::pstr;
void scan() { return; }
template <class T, typename... Args>
void scan(T &a, Args &&...args) {
  gi(a);
  scan(args...);
  return;
}
template <typename T>
void scann(T a, T b) {
  for (auto it = a; it != b; ++it) scan(*it);
}
template <typename T>
void scerr(T a, T b) {
  for (auto it = a; it != b; ++it) cerr << *it << " ";
  cerr << '\n';
}
void print() { return; }
template <class T, typename... Args>
void print(T a, Args... args) {
  gp(a);
  pc(' ');
  print(args...);
  return;
}
void cer() { return; }
template <class T, typename... Args>
void cer(T a, Args... args) {
  cerr << " " << a;
  cer(args...);
  return;
}
const int N = 2e5 + 100;
const int M = 1e6 + 2;
const long long mod = 998244353;
const int inf = 2e9 + 3;
const long long INF = 1e18;
void data() {}
int n, a[N], u[N], ans, glr, is[N];
vector<int> g[N], h[N], al[N], root;
void dfs(int v) {
  u[v] = 1;
  for (auto to : g[v]) {
    if (!u[to]) {
      dfs(to);
    }
  }
}
void dfs2(int v) {
  u[v] = 1;
  for (auto to : g[v]) {
    if (u[to]) {
      root.push_back(to);
    }
    if (u[to] == 0) {
      dfs2(to);
    }
  }
}
void al1(int v) {
  u[v] = 2;
  for (auto to : al[v]) {
    if (u[to] != 2) al1(to);
  }
}
int main() {
  data();
  scan(n);
  for (int i = 1; i <= n; ++i) {
    scan(a[i]);
    g[i].push_back(a[i]);
    h[a[i]].push_back(i);
    al[i].push_back(a[i]);
    al[a[i]].push_back(i);
  }
  for (int i = 1; i <= n; ++i) {
    if (a[i] == i) {
      root.push_back(i);
      al1(i);
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (!u[i]) {
      dfs2(i);
      al1(i);
    }
  }
  for (int i = 0; i < (int)root.size(); ++i) {
    if (a[root[i]] == root[i]) {
      glr = root[i];
    }
    is[root[i]] = 1;
  }
  if (glr) {
    for (int i = 1; i <= n; ++i) {
      if (is[i] && i != glr) {
        a[i] = glr;
        ans++;
      }
    }
    print(ans);
    pc('\n');
    for (int i = 1; i <= n; ++i) print(a[i]);
  } else {
    glr = root[0];
    for (int i = 1; i <= n; ++i) {
      if (is[i]) {
        a[i] = glr;
        ans++;
      }
    }
    print(ans);
    pc('\n');
    for (int i = 1; i <= n; ++i) print(a[i]);
  }
}