A masala:
n = input()
s=''
for i in n:
if(i=='/'):s+='/'
s+=i
q = f'print({s})'
exec(q)
B masala:
a=input().split()
for i in range(len(a)):
a[i]=(a[i][0:len(a[i])-1])[::-1]+a[i][-1]
print(*a)
C masala:
a=input()
if a=='Wrong answer':print("Noto'g'ri chiqish formati yoki dasturdagi algoritmik xato")
elif a=='Time limit exceeded':print('Dasturda samarasiz yechim yoki algoritmik xato')
elif a=='Presentation Error':print("Odatda barcha ehtimolliklarni hisobga olinmaganida chiqarish oqimiga javob chiqarilmay qolishi mumkin. Misol uchun if(i < 3) {cout << Output} bo'lganda, i qiymati 4 bo'lsa cout funksiyasi ishlamaydi va javob chiqarilmaydi shunda ushbu xatolik yuzaga keladi.")
elif a=='Compilation error':print("Dasturning sintaktik xatosi. Java tilida amalga oshirayotganda Main dan tashqari sinf ishlatilgan bo'lishi mumkin")
elif a=='Memory limit exceeded':print("Algoritmning samarasizligi yoki xotiraning noto'g'ri joylashishi")
elif a=='Runtime error':print("Ehtimol, dasturda massivning mavjud bo'lmagan elementiga murojaat qilish, nolga bo'lish va h.k. Ehtimol C ++ dasturi return 0 kodi bilan tugamagan yoki biron bir sababga ko'ra nolga teng bo'lmagan sonni qaytargan bo'lishi mumkin")
D masala:
dp = [0, 1]
for i in range(2, 30):
dp.append(dp[i-1]+dp[i-2])
# print(dp)
n,m = map(int, input().split())
print(pow(dp[n+1], dp[m+1]))
E masala:
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ap array<int, 2>
#define vap vector<ap>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vc vector<char>
#define vvc vector<vc>
void fast_io()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
void file_io(){
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
void print(vi arr){
for(auto x: arr){
cout << x << ' ';
}
cout << '\n';
}
void rec(string &a, string &b, int i, int j){
if(i == a.size() && j == b.size()){
cout << "YES\n";
exit(0);
}
if(a[i] == b[j]){
rec(a, b, i+1, j+1);
return;
}
if(b[j] == '?'){
rec(a, b, i+1, j+1);
return;
}
if(b[j] == '*'){
if(j==b.size()-1){
cout << "YES\n";
exit(0);
}
for(int k = i; a.size() > k; k++){
if(a[k] == b[j+1]){
rec(a, b, k, j+1);
}
}
}
}
vvi g;
vi visited;
vi loc;
void bfs(int v){
queue <int> q;
q.push(v);
while(!q.empty()){
int u = q.front();
q.pop();
visited[u] = 1;
loc.push_back(u);
for(auto x: g[u]){
if(visited[x] == 0){
q.push(x);
}
}
}
}
void solve()
{
int n, m;
cin >> n >> m;
vi arr(n);
for(int i = 0; n > i; i++) cin >> arr[i];
g.resize(n+1);
visited.resize(n+1, 0);
while(m--){
int l, r;
cin >> l >> r;
g[l-1].push_back(r-1);
g[r-1].push_back(l-1);
}
int ans = 0;
for(int i = 0; n > i; i++){
if(visited[i]==0){
loc.clear();
bfs(i);
set <int> brr;
for(auto x: loc){
brr.insert(arr[x]);
}
for(auto x: loc){
if(brr.count(x+1)){
ans ++;
}
}
}
}
cout << ans << '\n';
}
signed main(signed argc, char* argv[])
{
clock_t start = clock();
fast_io();
if(argc > 1 && string(argv[1]) == "gg") file_io();
int t = 1;
// cin >> t;
while (t--)
{
solve();
}
cerr << "Vaqt " << double(clock() - start) / double(CLOCKS_PER_SEC) * 1000 << " ms\n";
return 0;
}