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>
volatile bool isLocalTestEnabled = 0;
bool g_isLocalPrintEnabled = (bool)(0);
template <typename T>
void UpdateMin(T& a, const T b) {
  a = std::min(a, b);
}
template <typename T>
void UpdateMax(T& a, const T b) {
  a = std::max(a, b);
}
const long double Pi = std::atan(1.0L) * 4.0L;
static const long double Eps = 1.0e-09;
template <typename T>
bool IsEqual(const T a, const T b) {
  return std::abs(a - b) < Eps;
}
template <typename T>
bool IsGreater(const T a, const T b) {
  return a > b + Eps;
}
template <typename T>
bool IsLess(const T a, const T b) {
  return a + Eps < b;
}
template <typename T>
bool IsGreaterEqual(const T a, const T b) {
  return !IsLess(a, b);
}
template <typename T>
bool IsLessEqual(const T a, const T b) {
  return !IsGreater(a, b);
}
template <typename T>
std::string ToStr(const T& val) {
  std::ostringstream ostr;
  ostr << val;
  return ostr.str();
}
template <typename T>
bool FromStr(const std::string& str, T& val) {
  std::istringstream istr(str);
  istr >> val;
  return !!istr;
}
template <typename T>
std::istream& operator>>(std::istream& ist, std::vector<T>& data) {
  ;
  for (size_t i = 0; i < data.size(); i++) {
    ist >> data[i];
  }
  return ist;
}
template <typename T>
T Read(std::istream& ist) {
  ;
  T val;
  ist >> val;
  return val;
}
template <typename T>
std::ostream& operator<<(std::ostream& ost, const std::vector<T>& data) {
  for (size_t i = 0; i < data.size(); i++) {
    if (i != 0) {
      ost << ' ';
    }
    ost << data[i];
  }
  return ost;
}
template <size_t id>
class StopWatch {};
enum PartType { Loop = 1, Tree = 2 };
void Dfs(const std::vector<std::vector<size_t> >& undirectedLinks,
         const size_t start, std::vector<size_t>& isVisited,
         std::vector<size_t>& part) {
  ;
  isVisited[start] = 1;
  part.push_back(start);
  for (size_t i = 0; i < undirectedLinks[start].size(); i++) {
    const size_t next = undirectedLinks[start][i];
    if (isVisited[next]) continue;
    Dfs(undirectedLinks, next, isVisited, part);
  }
}
PartType GetPartType(const std::vector<size_t>& part,
                     const std::vector<size_t>& p, size_t& treeRoot) {
  size_t loopCount = 0;
  for (size_t i = 0; i < part.size(); i++) {
    const size_t vertex = part[i];
    if (p[vertex] == vertex) {
      loopCount += 1;
      treeRoot = vertex;
    }
  }
  if (loopCount == 0) return Loop;
  ;
  return Tree;
}
void DfsLoop(const std::vector<std::vector<size_t> >& undirectedLinks,
             const size_t prev, const size_t start,
             std::map<size_t, size_t>& isVisited, size_t& loopPoint) {
  ;
  isVisited[start] = 1;
  for (size_t i = 0; i < undirectedLinks[start].size(); i++) {
    const size_t next = undirectedLinks[start][i];
    if (isVisited[next]) {
      if (next != prev) loopPoint = next;
      continue;
    }
    DfsLoop(undirectedLinks, start, next, isVisited, loopPoint);
  }
}
size_t GetLoopPoint(const std::vector<std::vector<size_t> >& undirectedLinks,
                    const std::vector<size_t>& p,
                    const std::vector<size_t>& part) {
  for (size_t i = 0; i < part.size(); i++) {
    const size_t vertex = part[i];
    if (p[p[vertex]] == vertex) return vertex;
  }
  const size_t n = undirectedLinks.size();
  size_t loopPoint = n;
  std::map<size_t, size_t> isVisited;
  DfsLoop(undirectedLinks, part[0], part[0], isVisited, loopPoint);
  ;
  return loopPoint;
}
bool Solve(std::istream& ist, std::ostream& ost, const bool multipleTestMode) {
  StopWatch<1> sw;
  (void)sw;
  size_t n;
  ist >> n;
  if (multipleTestMode && !ist) return false;
  if (!g_isLocalPrintEnabled) {
  } else
    std::cerr << std::endl << "Next test" << std::endl;
  std::vector<size_t> p(n);
  for (size_t i = 0; i < n; i++) {
    ist >> p[i];
    --p[i];
  }
  std::vector<std::vector<size_t> > undirectedLinks(n);
  for (size_t i = 0; i < n; i++) {
    undirectedLinks[p[i]].push_back(i);
    undirectedLinks[i].push_back(p[i]);
  }
  std::vector<std::vector<size_t> > parts;
  std::vector<PartType> partTypes;
  std::vector<size_t> subtreeRoots;
  {
    std::vector<size_t> isVisited(n);
    for (size_t i = 0; i < n; i++) {
      if (isVisited[i]) continue;
      std::vector<size_t> part;
      Dfs(undirectedLinks, i, isVisited, part);
      size_t subtreeRoot = n;
      const PartType type = GetPartType(part, p, subtreeRoot);
      parts.push_back(part);
      partTypes.push_back(type);
      subtreeRoots.push_back(subtreeRoot);
    }
  }
  size_t firstTree = n;
  bool hasTree = false;
  for (size_t i = 0; i < parts.size(); i++) {
    if (partTypes[i] == Tree) {
      hasTree = true;
      firstTree = i;
      break;
    }
  }
  size_t replacements = 0;
  std::vector<size_t> ans = p;
  if (hasTree) {
    std::swap(parts[firstTree], parts[0]);
    std::swap(partTypes[firstTree], partTypes[0]);
    std::swap(subtreeRoots[firstTree], subtreeRoots[0]);
  } else {
    const size_t treeRoot = GetLoopPoint(undirectedLinks, p, parts[0]);
    ans[treeRoot] = treeRoot;
    replacements += 1;
  }
  for (size_t i = 1; i < parts.size(); i++) {
    if (partTypes[i] == Tree) {
      const size_t currPartVertex = subtreeRoots[i];
      ;
      const size_t prevPartVertex = parts[i - 1][0];
      ans[currPartVertex] = prevPartVertex;
    } else {
      ;
      const size_t currPartVertex = GetLoopPoint(undirectedLinks, p, parts[i]);
      ;
      const size_t prevPartVertex = parts[i - 1][0];
      ans[currPartVertex] = prevPartVertex;
    }
    replacements += 1;
  };
  for (size_t i = 0; i < n; i++) {
    ans[i] += 1;
  }
  ost << replacements << std::endl;
  ost << ans << std::endl;
  return multipleTestMode;
}
int main(int argc, const char* argv[]) {
  std::ios_base::sync_with_stdio(false);
  std::istream* ist = &std::cin;
  std::ostream* ost = &std::cout;
  std::unique_ptr<std::istream> fileInput;
  if (argc > 1) {
    fileInput.reset(new std::ifstream(argv[1]));
    if (!(*fileInput)) {
      std::cout << "File not found: " << argv[1] << std::endl;
    }
    ist = fileInput.get();
  }
  Solve(*ist, *ost, false);
}