#include<iostream>
#include<math.h>
#include<algorithm>
#include<fstream>
#include<string>
#include<map>
#include<math.h>
#include<vector>
#include <stdio.h>
#include <string.h>
#include<list>
using namespace std;
ofstream fo("output.txt");
ifstream fi("input.txt");
#define maxn 100010
#define N 200005
const int maxm = 50;
char Map[maxm][maxm];
int num[500005];
int main()
{
	map<string, string> a;
	vector<string>b;
	int n, m;
	string s1, s2;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> s1 >> s2;
		if (s1.length() > s2.length())
		{
			a[s1] = s2;
			a[s2] = s2;
		}
		else
		{
			a[s1] = s1;
			a[s2] = s1;
		}
	}

	for (int i = 0; i < m; i++)
	{
		string s3;
		cin >> s3;
		b.push_back(a[s3]);
	}
	for (int i = 0; i < m; i++)
		cout << b[i] << " ";
	cout << endl;
	//system("pause");
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
char s[m][3];
char s1[n];
for(int i=0;i<m;++i)
{
    cin>>s[i][0]>>s[i][1];
    if(strlen(s[i][0])>strlen(s[i][1]))
    s[i][2]=strlen(s[i][1]);
    else
     s[i][2]=strlen(s[i][0]);
}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==s[i][0])
    s1[i]=s[i][2];

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
 vector< pair <string,string> > v;

string s1[n];
for(int i=0;i<m;++i)
{
    cin>>v[i].first>>v[i].second;
    if(v[i].first.size()<v[i].second.size())
   v[i].second=v[i].first ;

}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    {
    if(s1[i]==v[i].first)
    s1[i]=v[i].second;
    }

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
char s[m][3];
char s1[n];
for(int i=0;i<m;++i)
{
    cin>>s[i][0]>>s[i][1];
    if(strlen(s[i][0])>strlen(s[i][1]))
    s[i][2]=strlen(s[i][1]);
    else
     s[i][2]=strlen(s[i][0]);
}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==s[i][0])
    s1[i]=s[i][2];

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
vector<string,string>v[m];
string s1[n];
for(int i=0;i<m;++i)
{
    cin>>v[i].first>>v[i].second;
    if(v[i].first.size()<v[i].second.size())
   v[i].second=v[i].first ;

}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==v[i].first)
    s1[i]=v[i].second;

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
 vector< pair <string,string> > v;

string s1[n];
for(int i=0;i<m;++i)
{
    cin>>v[i].first>>v[i].second;
    if(v[i].first.size()<v[i].second.size())
   v[i].second=v[i].first ;

}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==v[i].first)
    s1[i]=v[i].second;

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
 vector<string> v1;
  vector<string> v2;

string s1[n];
for(int i=0;i<m;++i)
{
    cin>>v1[i]>>v2[i];
    if(v1[i].size()<v2[i].size())
   v2[i]=v1[i] ;

}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int j=0;j<m;++j)
    {
    if(s1[i]==v1[j])
    {
    s1[i]=v2[j];
    break;
    }
    }
}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
 vector< pair <string,string> > v[m];

string s1[n];
for(int i=0;i<m;++i)
{
    cin>>v[i].first>>v[i].second;
    if(v[i].first.size()<v[i].second.size())
   v[i].second=v[i].first ;

}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==v[i].first)
    s1[i]=v[i].second;

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
char s[m][3];
char s1[n];
for(int i=0;i<m;++i)
{
    cin>>s[i][0]>>s[i][1];
    if(strlen(s[i][0])>strlen(s[i][1]))
    s[i][2]=s[i][1];
    else
     s[i][2]=s[i][0];
}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==s[i][0])
    s1[i]=s[i][2];

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
char s[m][3];
char s1[n];
for(int i=0;i<m;++i)
{
    cin>>s[i][0]>>s[i][1];
    if(strcmp(s[i][0],s[i][1]))
    s[i][2]=s[i][1];
    else
     s[i][2]=s[i][0];
}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==s[i][0])
    s1[i]=s[i][2];

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
char s[m][3];
char s1[n];
for(int i=0;i<m;++i)
{
    cin>>s[i][0]>>s[i][1];
    string s1=s[i][0];
    string s2=s[i][1];
    if(s1>.length()>s2.length())
    s[i][2]=s[i][1];
    else
     s[i][2]=s[i][0];
}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==s[i][0])
    s1[i]=s[i][2];

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
string s1,s2;
char s[m][3];
char s1[n];
for(int i=0;i<m;++i)
{
    cin>>s[i][0]>>s[i][1];
    if(s[i][0].length()>s[i][1].length())
    s[i][2]=s[i][1].length();
    else
     s[i][2]=s[i][0].length();
}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==s[i][0])
    s1[i]=s[i][2];

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
 vector<string > v1;
  vector<string > v2;

string s1[n];
for(int i=0;i<m;++i)
{
    cin>>v1[i]>>v2[i];
    if(v1[i].size()<v2[i].size())
   v2[i]=v1[i] ;

}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==v1[i])
    s1[i]=v2[i];

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
 vector<string > v1;
  vector<string > v2;

string s1[n];
for(int i=0;i<m;++i)
{
    cin>>v1[i]>>v2[i];
    if(v1[i].size()<v2[i].size())
   v2[i]=v1[i] ;

}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int j=0;j<m;++j)
    if(s1[i]==v1[j])
    s1[i]=v2[j];

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
vector<string,string>v[m]
char s1[n];
for(int i=0;i<m;++i)
{
    cin>>v[i].first>>v[i].second;
    if(v[i].first.size()<v[i].second.size())
   v[i].second=v[i].first ;

}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==v[i].first)
    s1[i]=v[i].second;

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
#define ff(i,s,e) for(int i=(s); i<e; i++)
using namespace std;
int main()
{
   vector<string>vs1;
   vector<string>vs2;
   int m , n;
   string a , b;
   cin>>n>>m;
   string mn[n];
   ff(i,0,m){
    string a , b;
    cin>>a>>b;
    vs1.push_back(a);
    vs2.push_back(b);
   }
   ff(i,0,n){
    cin>>mn[i];
   }
   ff(i,0,n){
    ff(j,0,m){
        if(mn[i]==vs1[j]){
            if(vs1[j].size()>vs2[j].size())
                cout<<vs2[j];
            else
                cout<<vs1[j];
            if(i!=n-1)
                cout<<" ";
            break;
        }
    }
   }

    return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
 vector<string > v1;
  vector<string > v2;

string s1[n];
for(int i=0;i<m;++i)
{
    cin>>v1[i]>>v2[i];
    if(v1[i].size()<v[2i].size())
   v2[i]=v1[i] ;

}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==v1[i])
    s1[i]=v2[i];

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
 vector<string> v1;
  vector<string> v2;

string s1[n];
for(int i=0;i<m;++i)
{
    cin>>v1[i]>>v2[i];
    if(v1[i].size()<v2[i].size())
   v2[i]=v1[i] ;

}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int j=0;j<m;++j)
    {
    if(s1[i]==v1[j])
    s1[i]=v2[j];
    }
}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
 vector<string> > v1;
  vector<string> > v2;

string s1[n];
for(int i=0;i<m;++i)
{
    cin>>v1[i]>>v2[i];
    if(v1[i].size()<v[2i].size())
   v2[i]=v1[i] ;

}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==v1[i])
    s1[i]=v2[i];

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
char s[m][3];
char s1[n];
for(int i=0;i<m;++i)
{
    cin>>s[i][0]>>s[i][1];
    if(strlen(s[i][0])>strlen(s[i][1]))
    s[i][2]=strlen(s[i][1]);
    else
     s[i][2]=strlen(s[i][0]);
}
for(int i=0;i<n;++i)
{
    cin>>s1[i];
    for(int i=0;i<m;++i)
    if(s1[i]==s[i][0])
    s1[i]=s[i][2];

}
for(int i=0;i<n;++i)
cout<<s1[i];
return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    unordered_map<string, string> m;
    int n, m = 0;
    string x, y;
    cin >> n >> m;
    while(m--){
        cin >> x >> y;
        m[x] = x.size() <= y.size() ? x : y;
        m[y] = x.size() <= y.size() ? x : y;
    }
    while(n--){
        cin >> x;
        cout << m[x] << " ";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    unordered_map<string, string> mp;
    int n, m = 0;
    string x, y;
    cin >> n >> m;
    while(m--){
        cin >> x >> y;
        mp[x] = x.size() <= y.size() ? x : y;
        mp[y] = x.size() <= y.size() ? x : y;
    }
    while(n--){
        cin >> x;
        cout << mp[x] << " ";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    unordered_map<string, string> mp;
    int n, m = 0;
    string x, y;
    cin >> n >> m;
    while(m--){
        cin >> x >> y;
        mp[x] = mp[y] = x.size() <= y.size() ? x : y;
        //m[y] = x.size() <= y.size() ? x : y;
    }
    while(n--){
        cin >> x;
        cout << mp[x] << " ";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    unordered_map<string, string> m;
    int n, m = 0;
    string x, y;
    cin >> n >> m;
    while(m--){
        cin >> x >> y;
        m[x] = m[y] = x.size() <= y.size() ? x : y;
        //m[y] = x.size() <= y.size() ? x : y;
    }
    while(n--){
        cin >> x;
        cout << m[x] << " ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define Template ll t;cin>>t;while(t--)
#define pb push_back
#define fr(a,n) for(ll i=a;i<n;i++)
#define optimize ios_base::sync_with_stdio(false);cin.tie(NULL);

int main(void){
	optimize
	ll n,m;cin>>n>>m;
	string s1[m],s2[m],s[n],r[n],a,a1,a2;
	map<string,string> ma;
	fr(0,m){
		cin>>s1[i]>>s2[i];
		ma[s1[i]]=s2[i];
		ma[s2[i]]=s1[i];
	}
	fr(0,n){
		cin>>a;
		if(ma[a].length()>a.length()){
			r[i]=a;
		}
		else if(ma[a].length()<a.length()){
			r[i]=ma[a];
		}
		else if(ma[a].length()==a.length()){
			for(int j=0;j<m;j++){
				if(a==s1[i] || ma[a]==s1[i])r[i]=s1[i];
			}
		}
	}
	fr(0,n){
		cout<<r[i]<<" ";
	}cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define Template ll t;cin>>t;while(t--)
#define pb push_back
#define fr(a,n) for(ll i=a;i<n;i++)
#define optimize ios_base::sync_with_stdio(false);cin.tie(NULL);

int main(void){
	optimize
	ll n,m;cin>>n>>m;
	string s1[m],s2[m],s[n],r[n],a,a1,a2;
	map<string,string> ma;
	fr(0,m){
		cin>>s1[i]>>s2[i];
		ma[s1[i]]=s2[i];
	}
	fr(0,n){
		cin>>a;
		if(ma[a].length()>=a.length()){
			r[i]=a;
		}
		else if(ma[a].length()<a.length()){
			r[i]=ma[a];
		}
	}
	fr(0,n){
		cout<<r[i]<<" ";
	}cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define Template ll t;cin>>t;while(t--)
#define pb push_back
#define fr(a,n) for(ll i=a;i<n;i++)
#define optimize ios_base::sync_with_stdio(false);cin.tie(NULL);

int main(void){
	optimize
	ll n,m;cin>>n>>m;
	string s1[m],s2[m],s[n],r[n],a,a1,a2;
	map<string,string> ma;
	fr(0,m){
		cin>>s1[i]>>s2[i];
		ma[s1[i]]=s2[i];
		ma[s2[i]]=s1[i];
	}
	fr(0,n){
		cin>>a;
		if(ma[a].length()>a.length()){
			r[i]=a;
		}
		else if(ma[a].length()<a.length()){
			r[i]=ma[a];
		}
		else if(ma[a].length()==a.length()){
			// for(int j=0;j<m;j++){
			// 	if(a==s1[i] || ma[a]==s1[i])r[i]=s1[i];
			// }
			r[i]="";
		}
	}
	fr(0,n){
		cout<<r[i]<<" ";
	}cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define Template ll t;cin>>t;while(t--)
#define pb push_back
#define fr(a,n) for(ll i=a;i<n;i++)
#define optimize ios_base::sync_with_stdio(false);cin.tie(NULL);

int main(void){
	optimize
	ll n,m;cin>>n>>m;
	string s1[m],s2[m],s[n],r[n],a,a1,a2;
	map<string,string> ma;
	fr(0,m){
		cin>>s1[i]>>s2[i];
		ma[s1[i]]=s2[i];
		ma[s2[i]]=s1[i];
	}
	fr(0,n){
		cin>>a;
		if(ma[a].length()>a.length()){
			r[i]=a;
		}
		else if(ma[a].length()<a.length()){
			r[i]=ma[a];
		}
		else if(ma[a].length()==a.length()){
			for(int j=0;j<m;j++){
				if(a==s1[i] || ma[a]==s1[i]){
					r[i]=s1[i];
					break;
				}
			}
		}
	}
	fr(0,n){
		cout<<r[i]<<" ";
	}cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    map<string,string> m;

    for(int i=0; i<m; i++){
        string a,b;
        cin >> a >> b;
        if(b.length()<a.length()){
            m[a]=b;
        }else{
            m[b]=a;
        }
    }
    string ans;
    for(int i=0; i<n; i++){
        cin >> ans;
        cout << m[ans] << " ";
    }
    cout << "\n";

}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    int n,mn;
    cin >> n >> mn;
    map<string,string> m;

    for(int i=0; i<mn; i++){
        string a,b;
        cin >> a >> b;
        if(b.length()<a.length()){
            m[a]=b;
        }else{
            m[b]=a;
        }
    }
    string ans;
    for(int i=0; i<n; i++){
        cin >> ans;
        cout << m[ans] << " ";
    }
    cout << "\n";

}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    int n,mn;
    cin >> n >> mn;
    map<string,string> m;

    for(int i=0; i<mn; i++){
        string a,b;
        cin >> a >> b;
        if(b.length()<a.length()){
            m[a]=b;
        }else{
            m[a]=a;
        }
    }
    string ans;
    for(int i=0; i<n; i++){
        cin >> ans;
        cout << m[ans] << " ";
    }
    cout << "\n";

}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    int n,mn;
    cin >> n >> mn;
    map<string,string> mn;

    for(int i=0; i<mn; i++){
        string a,b;
        cin >> a >> b;
        if(b.length()<a.length()){
            m[a]=b;
        }else{
            m[a]=a;
        }
    }
    string ans;
    for(int i=0; i<n; i++){
        cin >> ans;
        cout << m[ans] << " ";
    }
    cout << "\n";

}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    map<string,string> m;

    for(int i=0; i<m; i++){
        string a,b;
        cin >> a >> b;
        if(b.length()<a.length()){
            m[a]=b;
        }else{
            m[a]=a;
        }
    }
    string ans;
    for(int i=0; i<n; i++){
        cin >> ans;
        cout << m[ans] << " ";
    }
    cout << "\n";

}


#include <bits/stdc++.h>

using namespace std;

const int maxnm = 3000 + 20;
string a , b , f[maxnm][2] , g[maxnm];
int n = 0 , m = 0 , l1 = 0 , l2 = 0;
int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> f[i][0] >> f[i][1];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> g[i];
	}
	for (int i = 0 ; i < m ; i++)
	{
		l1 = (int) f[i][0].size();
		l2 = (int) f[i][1].size();
		if (l2 < l1)
		{
			for (int j = 0; j < n; j++)
			{
				if (f[i][0].compare(g[j]) == 0)
				{
					g[j] = f[i][1];
				}
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		cout << g[i] << " ";
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool k = true;
const int maxn = 3000 + 20;
string s , t , a , b , g[maxn];
int n = 0 , m = 0 , l1 = 0 , l2 = 0 , f = 0;
int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> s >> t;
		l1 = (int) s.size();
		l2 = (int) t.size();
		if (l2 < l1 && l1 - l2 > f)
		{
			f = l1 - l2;
			a = s;
			b = t;
		}
	}
	l1 = (int) a.size();
	for (int i = 0; i < n; i++)
	{
		cin >> g[i];
		s = g[i];
		for (int j = 0; j < l1; j++)
		{
			if (a[j] != s[j])
			{
				k = false;
			}
		}
		if (k == true)
		{
			g[i] = b;
		}
		k = true;
	}
	for (int i = 0; i < n; i++)
	{
		cout << g[i] << " ";
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool k = true;
const int maxn = 3000 + 20;
string s , t , a , b , g[maxn];
int n = 0 , m = 0 , l1 = 0 , l2 = 0;
int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> s >> t;
		l1 = (int) s.size();
		l2 = (int) t.size();
		if (l2 < l1)
		{
			a = s;
			b = t;
		}
	}
	l1 = (int) a.size();
	for (int i = 0; i < n; i++)
	{
		cin >> g[i];
		s = g[i];
		for (int j = 0; j < l1; j++)
		{
			if (a[j] != s[j])
			{
				k = false;
			}
		}
		if (k == true)
		{
			g[i] = b;
		}
		k = true;
	}
	for (int i = 0; i < n; i++)
	{
		cout << g[i] << " ";
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int maxnm = 3000 + 20;
string a , b , f[maxnm][2] , g[maxnm];
int n = 0 , m = 0 , l1 = 0 , l2 = 0;
int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> f[i][0] >> f[i][1];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> g[i];
	}
	for (int i = 0 ; i < m ; i++)
	{
		l1 = (int) f[i][0].size();
		l2 = (int) f[i][1].size();
		if (l2 < l1)
		{
			for (int j = 0; j < n; j++)
			{
				if (f[i][0].compare(g[i]) == 0)
				{
					g[i] = f[i][1];
				}
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		cout << g[i] << " ";
	}
	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int i,j,n,m;
    cin>>n>>m;
    string a[m],b[m],c[n];
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        cin>>b[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>c[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(c[i]==a[j])
            {
                if(a[j].length()>b[j].length())
                {
                    cout<<b[j]<<" ";
                }
                else
                {
                    cout<<a[j]<<" ";
                }
            }

        }
    }

    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int i,j,n,m;
    cin>>n>>m;
    string a[m],b[m],c[n];
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        cin>>b[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>c[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(c[i]==a[j])
            {
                if(a[j].length()<b[j].length())
                {
                    cout<<b[j]<<" ";
                }
                else
                {
                    cout<<a[i]<<" ";
                }
            }

        }
    }

    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int i,n,m;
    cin>>n>>m;
    string a[m],b[m],c[n];
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        cin>>b[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>c[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(c[i]==a[j]&&a[j].length()<b[j].length())
            {
                cout<<b[j]<<" ";
            }
            else
            {
                cout<<a[j]<<" ";
            }
        }
    }

    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int i,j,n,m;
    cin>>n>>m;
    string a[m],b[m],c[n];
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        cin>>b[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>c[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(c[i]==a[j])
            {
                if(a[j].length()<b[j].length())
                {
                    cout<<b[j]<<" ";
                }
                else
                {
                    cout<<a[j]<<" ";
                }
            }

        }
    }

    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int i,j,n,m;
    cin>>n>>m;
    string a[m],b[m],c[n];
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        cin>>b[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>c[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(c[i]==a[j]&&a[j].length()<b[j].length())
            {
                cout<<b[j]<<" ";
            }
            else
            {
                cout<<a[j]<<" ";
            }
        }
    }

    return 0;
}


#include<iostream>
#include<vector>
#include<string>
using namespace std;

string FindShorterWord(vector<vector<string>>arr, int m, string Find)
{
	int ChiSoDong;
	int Flag = 0;
	for (int i = 0; i < m; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			if (arr[i][j] == Find)
			{
				Flag = 1;
				ChiSoDong = i;
				break;
			}
		}
		if (Flag == 1)
		{
			break;
		}
	}
	int size_1 = arr[ChiSoDong][0].size();
	int size_2 = arr[ChiSoDong][1].size();
	if (size_1 < size_2 || size_1 == size_2)
	{
		return arr[ChiSoDong][0];
	}
	return arr[ChiSoDong][1];
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<string>>arr;
	vector<string>Lecture;
	vector<string>Temp;
	string value;

	arr.resize(m);
	for (int i = 0; i < m; ++i)
	{
		arr[i].resize(2);
		for (int j = 0; j < 2; ++j)
		{
			cin >> value;
			arr[i][j] = value;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cin >> value;
		Lecture.push_back(value);
	}

	for (int i = 0; i < n; ++i)
	{
		string s = FindShorterWord(arr, m, Lecture[i]);
		cout << s << " ";
	}

	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
using namespace std;

string FindShorterWord(vector<vector<string>>arr, int m, string Find)
{
	int ChiSoDong;
	int Flag = 0;
	for (int i = 0; i < m; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			if (arr[i][j] == Find)
			{
				Flag = 1;
				ChiSoDong = i;
				break;
			}
		}
		if (Flag == 1)
		{
			break;
		}
	}
	int size_1 = arr[ChiSoDong][0].size();
	int size_2 = arr[ChiSoDong][1].size();
	if (size_1 < size_2 || size_1 == size_2)
	{
		return arr[ChiSoDong][0];
	}
	return arr[ChiSoDong][1];
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<string>>arr;
	vector<string>Lecture;
	//vector<string>Temp;
	string value;

	arr.resize(m);
	for (int i = 0; i < m; ++i)
	{
		arr[i].resize(2);
		for (int j = 0; j < 2; ++j)
		{
			cin >> value;
			arr[i][j] = value;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cin >> value;
		Lecture.push_back(value);
	}
	int Length_Lecture = Lecture.size();
	for (int i = 0; i < Length_Lecture; ++i)
	{
		string s = FindShorterWord(arr, m, Lecture[i]);
		cout << s << " ";
		//Temp.push_back(s);
	}

	/*int size_Temp = Temp.size();
	for (int i = 0; i < size_Temp; ++i)
	{
		cout << Temp[i] << " ";
	}*/

	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
using namespace std;

string FindShorterWord(vector<vector<string>>arr, int m, string Find)
{
	int ChiSoDong;
	int Flag = 0;
	for (int i = 0; i < m; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			if (arr[i][j] == Find)
			{
				Flag = 1;
				ChiSoDong = i;
				break;
			}
		}
		if (Flag == 1)
		{
			break;
		}
	}

	if (arr[ChiSoDong][0].size() < arr[ChiSoDong][1].size() || arr[ChiSoDong][0].size() == arr[ChiSoDong][1].size())
	{
		return arr[ChiSoDong][0];
	}
	return arr[ChiSoDong][1];
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<string>>arr;
	vector<string>Lecture;
	vector<string>Temp;
	string value;

	arr.resize(m);
	for (int i = 0; i < m; ++i)
	{
		arr[i].resize(2);
		for (int j = 0; j < 2; ++j)
		{
			cin >> value;
			arr[i][j] = value;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cin >> value;
		Lecture.push_back(value);
	}

	for (int i = 0; i < n; ++i)
	{
		string s = FindShorterWord(arr, m, Lecture[i]);
		Temp.push_back(s);
	}

	for (int i = 0; i < n; ++i)
	{
		cout << Temp[i] << " ";
	}

	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
using namespace std;

string FindShorterWord(vector<vector<string>>arr, int m, string Find)
{
	int ChiSoDong;
	int Flag = 0;
	for (int i = 0; i < m; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			if (arr[i][j] == Find)
			{
				Flag = 1;
				ChiSoDong = i;
				break;
			}
		}
		if (Flag == 1)
		{
			break;
		}
	}

	if (arr[ChiSoDong][0].size() < arr[ChiSoDong][1].size() || arr[ChiSoDong][0].size() == arr[ChiSoDong][1].size())
	{
		return arr[ChiSoDong][0];
	}
	return arr[ChiSoDong][1];
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<string>>arr;
	vector<string>Lecture;
	vector<string>Temp;
	string value;

	arr.resize(m);
	for (int i = 0; i < m; ++i)
	{
		arr[i].resize(2);
		for (int j = 0; j < 2; ++j)
		{
			cin >> value;
			arr[i][j] = value;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cin >> value;
		Lecture.push_back(value);
	}

	for (int i = 0; i < n; ++i)
	{
		string s = FindShorterWord(arr, m, Lecture[i]);
		cout << s << " ";
	}

	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
using namespace std;

string FindShorterWord(vector<vector<string>>arr, int m, string Find)
{
	int ChiSoDong;

	for (int i = 0; i < m; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			if (arr[i][j] == Find)
			{
				ChiSoDong = i;
				break;
			}
		}
	}

	if (arr[ChiSoDong][0].size() < arr[ChiSoDong][1].size() || arr[ChiSoDong][0].size() == arr[ChiSoDong][1].size())
	{
		return arr[ChiSoDong][0];
	}
	return arr[ChiSoDong][1];
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<string>>arr;
	vector<string>Lecture;
	vector<string>Temp;
	string value;

	arr.resize(m);
	for (int i = 0; i < m; ++i)
	{
		arr[i].resize(2);
		for (int j = 0; j < 2; ++j)
		{
			cin >> value;
			arr[i][j] = value;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cin >> value;
		Lecture.push_back(value);
	}

	int length_Lecture = Lecture.size();

	for (int i = 0; i < length_Lecture; ++i)
	{
		string s = FindShorterWord(arr, m, Lecture[i]);
		Temp.push_back(s);
	}

	int size = Temp.size();
	for (int i = 0; i < size; ++i)
	{
		cout << Temp[i] << " ";
	}

	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<string>>arr;
	vector<string>Lecture;
	//vector<string>Temp;
	string value;

	arr.resize(m);
	for (int i = 0; i < m; ++i)
	{
		arr[i].resize(2);
		for (int j = 0; j < 2; ++j)
		{
			cin >> value;
			arr[i][j] = value;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cin >> value;
		Lecture.push_back(value);
	}

	int k = 0,Flag,ChiSoDong;
	while (k < n)
	{
		Flag = 0;
		for (int i = 0; i < m; ++i)
		{
			for (int j = 0; j < 2; ++j)
			{
				if (arr[i][j] == Lecture[k])
				{
					ChiSoDong = i;
					Flag = 1;
					break;
				}
			}
			if (Flag == 1)
			{
				int size_1 = arr[ChiSoDong][0].size();
				int size_2 = arr[ChiSoDong][1].size();
				if (size_1 < size_2 || size_1 == size_2)
				{
					cout << arr[ChiSoDong][0] << " ";
				}
				else
				{
					cout << arr[ChiSoDong][1] << " ";
				}
				break;
			}
		}
		k++;
	}

	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
using namespace std;

string FindShorterWord(vector<vector<string>>arr, int m, string Find)
{
	int ChiSoDong;
	int Flag = 0;
	for (int i = 0; i < m; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			if (arr[i][j] == Find)
			{
				Flag = 1;
				ChiSoDong = i;
				break;
			}
		}
		if (Flag == 1)
		{
			break;
		}
	}

	if (arr[ChiSoDong][0].size() < arr[ChiSoDong][1].size() || arr[ChiSoDong][0].size() == arr[ChiSoDong][1].size())
	{
		return arr[ChiSoDong][0];
	}
	return arr[ChiSoDong][1];
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<string>>arr;
	vector<string>Lecture;
	vector<string>Temp;
	string value;

	arr.resize(m);
	for (int i = 0; i < m; ++i)
	{
		arr[i].resize(2);
		for (int j = 0; j < 2; ++j)
		{
			cin >> value;
			arr[i][j] = value;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cin >> value;
		Lecture.push_back(value);
	}

	int length_Lecture = Lecture.size();

	for (int i = 0; i < length_Lecture; ++i)
	{
		string s = FindShorterWord(arr, m, Lecture[i]);
		Temp.push_back(s);
	}

	int size = Temp.size();
	for (int i = 0; i < size; ++i)
	{
		cout << Temp[i] << " ";
	}

	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
using namespace std;

string FindShorterWord(vector<vector<string>>arr, int m, string Find)
{
	int ChiSoDong;
	int Flag = 0;
	for (int i = 0; i < m; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			if (arr[i][j] == Find)
			{
				Flag = 1;
				ChiSoDong = i;
				break;
			}
		}
		if (Flag == 1)
		{
			break;
		}
	}
	int size_1 = arr[ChiSoDong][0].size();
	int size_2 = arr[ChiSoDong][1].size();
	if (size_1 < size_2 || size_1 == size_2)
	{
		return arr[ChiSoDong][0];
	}
	return arr[ChiSoDong][1];
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<string>>arr;
	vector<string>Lecture;
	vector<string>Temp;
	string value;

	arr.resize(m);
	for (int i = 0; i < m; ++i)
	{
		arr[i].resize(2);
		for (int j = 0; j < 2; ++j)
		{
			cin >> value;
			arr[i][j] = value;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cin >> value;
		Lecture.push_back(value);
	}
	int Length_Lecture = Lecture.size();
	for (int i = 0; i < Length_Lecture; ++i)
	{
		string s = FindShorterWord(arr, m, Lecture[i]);
		//cout << s << " ";
		Temp.push_back(s);
	}

	int size_Temp = Temp.size();
	for (int i = 0; i < size_Temp; ++i)
	{
		cout << Temp[i] << " ";
	}

	//system("pause");
	return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <functional>
#include <algorithm>
#include <string>

using namespace std;

struct note {
	string first, second;
};

struct word {
	int n;
	string name, replace;
};

bool sortOriginal(word a, word b) {
	return a.n < b.n;
}

bool compareWords(word a, word b) {
	return a.name <= b.name;
}

bool compareString(note a, note b) {
	return a.first <= b.first;
}

void printDenoteString(int n, int m, vector<note> lang, string result) {
	int i = 0, pos = 0, start = 0, p1 = 0, p2 = 0;
	vector<word> v;
	word wor;
	string s(""), replace("");

	sort(lang.begin(), lang.end(), compareString);

	while (i <= n - 1) {
		if (i != n - 1) {
			pos = result.find(" ", pos + 1);
		} else {
			pos = result.length();
		}

		string tmp(result, start, pos - start);
		wor.n = i;
		wor.name = tmp;
		wor.replace = "";
		v.push_back(wor);

		start = pos + 1;
		i++;
	}

	sort(v.begin(), v.end(), compareWords);

	for (; p1 < m; p1++) {
		if (lang[p1].first.length() <= lang[p1].second.length()) {
			replace = lang[p1].first;
		} else {
			replace = lang[p1].second;
		}

		while (v[p2].name == lang[p1].first) {
			v[p2].replace = replace;
			p2++;
		}
	}

	sort(v.begin(), v.end(), sortOriginal);

	for (int p = 0; p < n; p++) {
		if (p != n - 1) {
			cout << v[p].replace << " ";
		} else {
			cout << v[p].replace << endl;
		}
	}
}

int main() {
	int n, m;
	string first(""), second(""), result("");
	note Note;
	vector<note> lang;

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> Note.first >> Note.second;

		lang.push_back(Note);
	}

	cin.ignore();
	getline(cin, result);

	printDenoteString(n, m, lang, result);

	return 0;
}


#include <iostream>
#include <vector>
#include <string>

using namespace std;

struct note {
	string min, max;
};

void printDenoteString(int n, int m, vector<note> lang, string result) {
	int i = 0, p = 0, pos = 0, start = 0;
	vector<string> v;
	string s("");

	while (i <= n - 1) {
		if (i != n - 1) {
			pos = result.find(" ", pos + 1);
		} else {
			pos = result.length();
		}

		v.push_back(result.substr(start, pos - start));

		start = pos + 1;
		i++;
	}

	for (; p < v.size(); p++) {
		for (int a = 0; a < lang.size(); a++) {
			if (v[p] == lang[a].min) {
				s += v[p] + " ";
				break;
			}

			if (v[p] != lang[a].min && v[p] == lang[a].max) {
				if (p < v.size() - 1) {
					s += lang[a].min + " ";
				} else {
					s += lang[a].min;
				}

				break;
			}
		}
	}

	cout << s << endl;
}

int main() {
	int n, m;
	string first(""), second(""), result("");
	note Note;
	vector<note> lang;

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> first >> second;

		if (first.length() <= second.length()) {
			Note.min = first;
			Note.max = second;
		} else {
			Note.min = second;
			Note.max = first;
		}

		lang.push_back(Note);
	}

	cin.ignore();
	getline(cin, result);

	printDenoteString(n, m, lang, result);

	return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <functional>
#include <string>

using namespace std;

struct note {
	string first, second;
};

struct word {
	int n;
	string name, replace;
};

bool sortOriginal(word a, word b) {
	return a.n < b.n;
}

bool compareWords(word a, word b) {
	return a.name <= b.name;
}

bool compareString(note a, note b) {
	return a.first <= b.first;
}

void printDenoteString(int n, int m, vector<note> lang, string result) {
	int i = 0, pos = 0, start = 0, p1 = 0, p2 = 0;
	vector<word> v;
	word wor;
	string s(""), replace("");

	sort(lang.begin(), lang.end(), compareString);

	while (i <= n - 1) {
		if (i != n - 1) {
			pos = result.find(" ", pos + 1);
		} else {
			pos = result.length();
		}

		string tmp(result, start, pos - start);
		wor.n = i;
		wor.name = tmp;
		wor.replace = "";
		v.push_back(wor);

		start = pos + 1;
		i++;
	}

	sort(v.begin(), v.end(), compareWords);

	for (; p1 < m; p1++) {
		if (lang[p1].first.length() <= lang[p1].second.length()) {
			replace = lang[p1].first;
		} else {
			replace = lang[p1].second;
		}

		while (v[p2].name == lang[p1].first) {
			v[p2].replace = replace;
			p2++;
		}
	}

	sort(v.begin(), v.end(), sortOriginal);

	for (int p = 0; p < n; p++) {
		if (p != n - 1) {
			cout << v[p].replace << " ";
		} else {
			cout << v[p].replace << endl;
		}
	}
}

int main() {
	int n, m;
	string first(""), second(""), result("");
	note Note;
	vector<note> lang;

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> Note.first >> Note.second;

		lang.push_back(Note);
	}

	cin.ignore();
	getline(cin, result);

	printDenoteString(n, m, lang, result);

	return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <functional>
#include <algorithm>
#include <string>

using namespace std;

struct note {
	string first, second;
};

struct word {
	int n;
	string name, replace;
};

bool sortOriginal(word a, word b) {
	return a.n < b.n;
}

bool compareWords(word a, word b) {
	return a.name <= b.name;
}

bool compareString(note a, note b) {
	return a.first <= b.first;
}

void printDenoteString(int n, int m, vector<note> lang, string result) {
	int i = 0, p = 0, pos = 0, start = 0, p1 = 0, p2 = 0;
	vector<word> v;
	word wor;
	string replace("");

	sort(lang.begin(), lang.end(), compareString);

	while (i <= n - 1) {
		if (i != n - 1) {
			pos = result.find(" ", pos + 1);
		} else {
			pos = result.length();
		}

		wor.n = i;
		wor.name = result.substr(start, pos - start);
		wor.replace = "";
		v.push_back(wor);

		start = pos + 1;
		i++;
	}

	sort(v.begin(), v.end(), compareWords);

	for (; p1 < m; p1++) {
		if (lang[p1].first.length() <= lang[p1].second.length()) {
			replace = lang[p1].first;
		} else {
			replace = lang[p1].second;
		}

		while (v[p2].name == lang[p1].first) {
			v[p2].replace = replace;
			p2++;
		}
	}

	sort(v.begin(), v.end(), sortOriginal);

	for (; p < n; p++) {
		if (p != n - 1) {
			cout << v[p].replace << " ";
		} else {
			cout << v[p].replace << endl;
		}
	}
}

int main() {
	int n, m;
	string first(""), second(""), result("");
	note Note;
	vector<note> lang;

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> Note.first >> Note.second;

		lang.push_back(Note);
	}

	cin.ignore();
	getline(cin, result);

	printDenoteString(n, m, lang, result);

	return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    string arr[2*m];
    for(int i=0;i<2*m;i++)
    {
        cin>>arr[i];
    }
    string brr[n];
    for(int i=0;i<n;i++)
    {
        cin>>brr[i];
    }
    for(int i=0;i<n;i++)
    {
      for(int w=0;w<2*m;w+=2)
      {
        if(brr[i]==arr[w])
        {
          int t=arr[w].length();
          int r=arr[w+1].length();
          if(r<t)
          {
            brr[i]=arr[w+1];
          }

        }
      }
      cout<<brr[i]<<" ";
    }

}


#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    string l1[m],l2[m],s[n];
    for(int i=0;i<m;i++)
    {
        cin>>l1[i]>>l2[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }

    for(int i=0;i<n;i++)
    {
        for(int f=0;f<m;i++)
        {
            if(l2[f].length()<l1[f].length()&&s[i]==l1[f])
            {
                s[i]=l2[f];
            }
        }

        cout<<s[i]<<" ";
    }

}


#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    string l1[m],l2[m],s[n];
    for(int i=0;i<m;i++)
    {
        cin>>l1[i]>>l2[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }

    for(int i=0;i<n;i++)
    {
        for(int f=0;f<m;i++)
        {
            if(l2[f].length()<l1[f].length()&&s[i]==l1[f])
            {
                s[i]=l2[f];
            }
        }
    }

    for(int i=0;i<n;i++)
    {
        cout<<s[i]<<" ";
    }
}


#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    string arr[6];
    for(int i=0;i<6;i++)
    {
        cin>>arr[i];
    }
    string brr[n];
    for(int i=0;i<n;i++)
    {
        cin>>brr[i];
    }
    for(int i=0;i<n;i++)
    {
         if(brr[i]==arr[0])
            {
                int p=arr[0].length();
                int q=arr[1].length();
                if(q<p)
                {
                    brr[i]=arr[1];
                }
            }
        else if(brr[i]==arr[2])
        {
            if(brr[i]==arr[2])
            {
                int p=arr[2].length();
                int q=arr[3].length();
                if(q<p)
                {
                    brr[i]=arr[3];
                }
            }
        }
        else if(brr[i]==arr[2])
         {
            if(brr[i]==arr[4])
            {
                int p=arr[4].length();
                int q=arr[5].length();
                if(q<p)
                {
                    brr[i]=arr[5];
                }
            }
         }

        cout<<brr[i]<<" ";
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
  int t;
  cin>>t;
  while(t--)
  {
    int n;
    int flag=0;
    cin>>n;
    int x[n],y[n];
    for(int i=0;i<n;i++)
    {
      cin>>x[i]>>y[i];
    }

     for(int i=0;i<n-1;i++)
        {
          if(x[i]>x[i+1]||y[i]>y[i+1]||x[i]==x[i+1]&&y[i]>y[i+1]||x[i]==x[i+1]&&y[i]<y[i+1])
          {
            flag=1;
            break;
          }
        }

    if(flag==0)
    {
      cout<<"YES"<<endl;
    }
    else if(flag==1)
    {
      cout<<"NO"<<endl;
    }
  }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
map<string,string>mp;
int n,d;
string a,b,c,f;
cin>>n>>d;
while(d--)
{
	cin>>a>>b;
	if(a.length()<b.length())c=b;
	else c=a;
	mp[a]=c;

}
while(n--)
{
	cin>>f;
	cout<<mp[f]<<" ";
}return 0;}


#include<bits/stdc++.h>
using namespace std;
int main()
{
map<string,string>mp;
int n,d;
string a,b,c,f;
cin>>n>>d;
while(d--)
{
	cin>>a>>b;
	if(b.length()<a.length())c=b;
	else c=a;
	mp[a]=c;

}
while(n--)
{
	cin>>f;
	cout<<mp[f]<<" ";
}return 0;}


#include<bits/stdc++.h>
using namespace std;
int main()
{
map<string,string>mp;
int n,d;
string a,b,c,f;
cin>>n>>d;
while(d--)
{
	cin>>a>>b;
	if(a.length()<b.length())c=a;
	else c=b;
	mp[a]=c;

}
while(n--)
{
	cin>>f;
	cout<<mp[f]<<" ";
}return 0;}


#include <bits/stdc++.h>

using namespace std;
int n,a;
string b[3001],c[3001],d[3001],g[3001];
int main(){
    cin >> n >> a;
    for(int i = 1; i<= a; i++){
        cin >> b[i] >> c[i];
    }
    for(int i =1 ; i<= n ; i++){
        cin >> d[i];
        for(int j =1 ; j<= a; j++){
            if(d[i] == b[j] || d[i] == c[j]){
                if(b[j].size() > c[j].size()){
                    g[i] = c[j];
                    break;
                }
                else if (c[j].size() > b[j].size()){
                    g[i] = b[j];
                    break;
                }
                else{
                    for(int t = 0 ; t < c[j].size();t++ ){
                        if(b[j][t] > c[j][t]){
                            g[i] = b[j];
                            break;
                        }
                        else if (c[j][t] > b[j][t]){
                            g[i] = c[j];
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }
    for(int  i=1; i<= n ; i++){
        cout << g[i] << " ";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,a;
string b[3001],c[3001],d[3001],g[3001];
int main(){
    cin >> n >> a;
    for(int i = 1; i<= a; i++){
        cin >> b[i] >> c[i];
    }
    for(int i =1 ; i<= n ; i++){
        cin >> d[i];
        for(int j =1 ; j<= a; j++){
            if(d[i] == b[j] || d[i] == c[j]){
                if(b[j].size() > c[j].size()){
                    g[i] = c[j];
                    break;
                }
                else if (c[j].size() > b[j].size()){
                    g[i] = b[j];
                    break;
                }
                else{
                    if(b[j] > c[j]){
                        g[i] = c[j];
                        break;
                    }
                    else{
                        g[i] = b[j];
                        break;
                    }
                }
            }
        }
    }
    for(int  i=1; i<= n ; i++){
        cout << g[i] << " ";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,a;
string b[3001],c[3001],d[3001],g[3001];
int main(){
    cin >> n >> a;
    for(int i = 1; i<= a; i++){
        cin >> b[i] >> c[i];
    }
    for(int i =1 ; i<= n ; i++){
        cin >> d[i];
        for(int j =1 ; j<= a; j++){
            if(d[i] == b[j] || d[i] == c[j]){
                if(b[j].size() > c[j].size()){
                    g[i] = c[j];
                    break;
                }
                else if (c[j].size() > b[j].size()){
                    g[i] = b[j];
                    break;
                }
                else{
                   g[i] = b[j];
                }
            }
        }
    }
    for(int  i=1; i<= n ; i++){
        cout << g[i] << " ";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,a;
string b[3001],c[3001],d[3001],g[3001];
int main(){
    cin >> n >> a;
    for(int i = 1; i<= a; i++){
        cin >> b[i] >> c[i];
    }
    for(int i =1 ; i<= n ; i++){
        cin >> d[i];
        for(int j =1 ; j<= a; j++){
            if(d[i] == b[j] || d[i] == c[j]){
                if(b[j].size() > c[j].size()){
                    g[i] = c[j];
                    break;
                }
                else if (c[j].size() > b[j].size()){
                    g[i] = b[j];
                    break;
                }
                else{
                    for(int t = 0 ; t < c[j].size();t++ ){
                        if(b[j][t] > c[j][t]){
                            g[i] = c[j];
                            break;
                        }
                        else if (c[j][t] > b[j][t]){
                            g[i] = b[j];
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }
    for(int  i=1; i<= n ; i++){
        cout << g[i] << " ";
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,m;
cin>>n>>m;
string a[m],b[m];
for(int i=0;i<m;++i)
{
    cin>>a[i]>>b[i];

}

for(int i=0;i<n;++i)
{
    string s;
    cin>>s;
    for(int j=0;j<m;++j)
    {
        if(s==a[j]||s==b[j])
        {   if(a[j].size()<=b[j].size())

            {cout<<a[j]<<" ";
        }
        else
            cout<<b[j]<<" ";
        break;
        }

    }
}

  return 0;
  }


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,m;
cin>>n>>m;
string a[n],b[n],c[n];
for(int i=0;i<m;++i)
{
    cin>>a[i]>>b[i];
    if(a[i].size()<=b[i].size())
        c[i]=a[i];
    else
        c[i]=b[i];
}

for(int i=0;i<n;++i)
{
    string s;
    cin>>s;
    for(int j=0;j<m;++j)
    {
        if(s==a[j]||s==b[j])
        {
            cout<<c[j]<<" ";break;
        }
    }
}

  return 0;
  }


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,m;
cin>>n>>m;
string a[n],b[n],c[n];
for(int i=0;i<m;++i)
{
    cin>>a[i];cin>>b[i];
    if(a[i].size()<=b[i].size())
        c[i]=a[i];
    else
        c[i]=b[i];
}

for(int i=0;i<n;++i)
{
    string s;
    cin>>s;
    for(int j=0;j<m;++j)
    {
        if(s==a[j]||s==b[j])
        {
            cout<<c[j]<<" ";break;
        }
    }
}

  return 0;
  }


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,m;
cin>>n>>m;
string a[n],b[n];
for(int i=0;i<m;++i)
{
    cin>>a[i]>>b[i];

}

for(int i=0;i<n;++i)
{
    string s;
    cin>>s;
    for(int j=0;j<m;++j)
    {
        if(s==a[j]||s==b[j])
        {   if(a[j].size()<=b[j].size())

            {cout<<a[j]<<" ";
        }
        else
            cout<<b[j]<<" ";
        break;
        }

    }
}

  return 0;
  }


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int check(int a, int b)
{
    if(a<b)
        return 0;
    return 1;
}
int main()
 {

     map<string,pair<int,int> > k;
     int n,m;
      cin>>n>>m;
     string a[m],b[m];
     for(int i=0;i<m;i++)
     {

         cin>>a[i]>>b[i];
         k[a[i]]=make_pair(check(a[i].length(),b[i].length()),i);
     }
     for(int i=0;i<n;i++)
     {
          string s;
          if(k[s].first==1)
            cout<<b[k[s].second]<<" ";
        else
            cout<<a[k[s].second]<<" ";
     }
     return 0;

}


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int check(int a, int b)
{
    if(a<b)
        return 0;
    return 1;
}
int main()
 {

     map<string,pair<int,int> > k;
     int n,m;
      cin>>n>>m;
     string a[m],b[m];
     for(int i=0;i<m;i++)
     {

         cin>>a[i]>>b[i];
         k[a[i]]=({check(a[i].length(),b[i].length()),i});
     }
     for(int i=0;i<n;i++)
     {
          string s;
          if(k[s]==1)
            cout<<b[k[s].second.second]<<" ";
        else
            cout<<a[k[s].second.second]<<" ";
     }
     return 0;

}


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int check(int a, int b)
{
    if(a<b)
        return 0;
    return 1;
}
int main()
 {

     map<string,pair<int,int> > k;
     int n,m;
      cin>>n>>m;
     string a[m],b[m];
     for(int i=0;i<m;i++)
     {

         cin>>a[i]>>b[i];
         k[a[i]]=(make_pair(check(a[i].length(),b[i].length()),i));
     }
     for(int i=0;i<n;i++)
     {
          string s;
          if(k[s].second.first==1)
            cout<<b[k[s].second]<<" ";
        else
            cout<<a[k[s].second]<<" ";
     }
     return 0;

}


#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int check(int a, int b)
{
    if(a<b)
        return 0;
    return 1;
}
int main()
 {

     map<string,pair<int,int> > k;
     int n,m;
      cin>>n>>m;
     string a[m],a[m];
     for(int i=0;i<m;i++)
     {

         cin>>a[i]>>b[i];
         k[a[i]]=({check(a[i].length(),b[i].length(),i});
     }
     for(int i=0;i<n;i++)
     {
          string s;
          if(k[s]==1)
            cout<<b[k[s].second.second]<<" ";
        else
            cout<<a[k[s].second.second]<<" ";
     }
     return 0;

}


#include <string>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int toInt(string s) {int res;stringstream ss;ss<<s;ss>>res;return res;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

typedef long long ll;
typedef unsigned long long ull;

typedef tuple<int,int> int2;
typedef tuple<int,int,int> int3;
typedef tuple<int,int,int,int> int4;

#define all(v) (v).begin(), (v).end()
#define est(v,e) (find(all(v), (e)) != (v).end())
#define eb emplace_back
#define SZ(a) (int((a).size()))
#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) For(i,0,n)
#define tag(i,v) rep(i,SZ(v))
#define trace(x)  cerr << #x << " = " << (x) << endl
#define tracev(x) cerr << #x << " = "; tag(__i, x) { cerr << x[__i] << ","; } cerr << endl

const int inf = 1 << 27;

int main(void) {

  string s;
  cin >> s;

  int ans = 0;
  while(true){
    if(s.size()==1)break;
    ans++;
    int t = 0;
    tag(i,s){
      t += s[i]-'0';
    }
    stringstream ss;
    ss << t;
    s = ss.str();
  }
  cout << ans << endl;
}


#include <iostream>
using namespace std;

string s;

int eval(string s) {
	if(s.length() == 1)
		return 0;

	int sum = 0;
	for(int i = 0; i < s.length(); i++)
		sum += s[i] - '0';

	return 1 + eval(to_string(sum));
}

int main() {
	cin >> s;
	cout << eval(s) << endl;
}


#include <iostream>
#include <sstream>
using namespace std;

string s;

string to_string(int a) {
	stringstream ss;
	ss << a;
	return ss.str();
}

int eval(string s) {
	if(s.length() == 1)
		return 0;

	int sum = 0;
	for(int i = 0; i < s.length(); i++)
		sum += s[i] - '0';

	return 1 + eval(to_string(sum));
}

int main() {
	cin >> s;
	cout << eval(s) << endl;
}


#include <string>
#include <iostream>
using namespace std;

string s;

int eval(string s) {
	if(s.length() == 1)
		return 0;

	int sum = 0;
	for(int i = 0; i < s.length(); i++)
		sum += s[i] - '0';

	return 1 + eval(to_string(sum));
}

int main() {
	cin >> s;
	cout << eval(s) << endl;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>

#define xx first
#define yy second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define MAX 2000000000
using namespace std;

int dirx[8] = {1,0,-1,0,1,-1,-1,1};
int diry[8] = {0,1,0,-1,1,1,-1,-1};

string str;

main() {
    //freopen("input.in","r",stdin);
    int ans = 0, cnt = 0, a;
    cin >> str;
    if(str.size()==1) {
        cout << 1;return 0;
    }
    for(int i=0;i<str.size();i++) ans += (str[i]-'0');
    while(ans>9) {
        cnt ++;
        a = 0;
        while(ans>0) {
            a += ans%10;
            ans /= 10;
        }
        ans = a;
    }
    cout << cnt+1;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>

#define xx first
#define yy second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define MAX 2000000000
using namespace std;

int dirx[8] = {1,0,-1,0,1,-1,-1,1};
int diry[8] = {0,1,0,-1,1,1,-1,-1};

string str;

main() {
    //freopen("input.in","r",stdin);
    int ans = 0, cnt = 0, a;
    cin >> str;
    if(str.size()==1) {
        cout << 0;return 0;
    }
    for(int i=0;i<str.size();i++) ans += (str[i]-'0');
    while(ans>9) {
        cnt ++;
        a = 0;
        while(ans>0) {
            a += ans%10;
            ans /= 10;
        }
        ans = a;
    }
    cout << cnt+1;
    return 0;
}


# include <iostream>
# include <vector>
# include <queue>
# include <deque>
# include <stack>
# include <set>
# include <string>
# include <algorithm>
# include <cstdio>
# include <cstdlib>
# include <map>
# include <cmath>
# include <bitset>
# include <list>
# include <sstream>

using namespace std;

string toString(int val)
{
    ostringstream os;
    os << val;
    return os.str();
}

int tf(string& str)
{
    int res = 0;
    for(int i=0; i<str.size(); ++i)
    {
        res += str[i]- '0';
    }

    return res;
}

int main(){
 //   freopen("input.txt", "r", stdin);
   //  freopen("output.txt", "w", stdout);

    string init;
    cin >> init;

    int ans = 0;
    while(init.size() != 1)
    {
        ++ans;
        int z = tf(init);
        init = toString(z);
    }

    cout << ans;
    return 0;
}


#include"stdio.h"
int cnt=0,i;
char arr[100005];
void sum(){
	int t=0;
	for(i=0;arr[i];i++)
		t+=arr[i]-48;
	sprintf(arr,"%d",t);
}
int main(){
	scanf("%s",arr);
	while(1){
		if(arr[1]==0)break;
		sum(); cnt++;
	}
	printf("%d",cnt);
	return 0;
}


#include<stdio.h>
#include<string.h>
int sm;
int f(int n)
{
     sm=0;int s;
     while(n>0)
         {
             s=n%10;
            //  printf("%d---",s);
             sm=sm+s;
              n=n/10;
               //printf("%d\n",n);
         }
         return sm;
        // printf("%d",sm);
}
int main()
{
    int n=0,cnt=0,z,i;
    char c[100005];
    scanf("%s",c);
    for(i=0;i<strlen(c);i++)
    {
        n=n+(c[i]-'0');
    }
    if(strlen(c)==1)
    {
        printf("0");
        return 0;
    }
   // while(t--)
      //   printf("..%d\n",n);
       //  w=n;
         while(n>=10)
         {
             z=f(n);
             cnt++;
            // printf("%d\n",z);
             n=z;
         }
          printf("%d",cnt+1);

    return 0;
}


#include<stdio.h>
int sm;
int f(int n)
{
     sm=0;int s;
     while(n>0)
         {
             s=n%10;
            //  printf("%d---",s);
             sm=sm+s;
              n=n/10;
               //printf("%d\n",n);
         }
         return sm;
        // printf("%d",sm);
}
int main()
{
    int n,cnt=0,z;
    //scanf("%d",&t);
   // while(t--)
         scanf("%d",&n);
       //  w=n;
         while(n>=10)
         {
             z=f(n);
             cnt++;
            // printf("%d\n",z);
             n=z;
         }
          printf("%d",cnt);

    return 0;
}


#include<stdio.h>
#include<string.h>
int sm;
int f(int n)
{
     sm=0;int s;
     while(n>0)
         {
             s=n%10;
            //  printf("%d---",s);
             sm=sm+s;
              n=n/10;
               //printf("%d\n",n);
         }
         return sm;
        // printf("%d",sm);
}
int main()
{
    int n=0,cnt=0,z,i;
    char c[100005];
    scanf("%s",c);
    for(i=0;i<strlen(c);i++)
    {
        n=n+(c[i]-'0');
    }
   // while(t--)
      //   printf("..%d\n",n);
       //  w=n;
         while(n>=10)
         {
             z=f(n);
             cnt++;
            // printf("%d\n",z);
             n=z;
         }
          printf("%d",cnt+1);

    return 0;
}


//Bismillahir rahmanir rahim

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void) {
	// your code goes here
	char num[100001];
	gets(num);
	int i,c=0, y,sum=0;
	y = strlen(num);
	if(y<2){
	    goto asd;
	}
	qer:
	for(i=0;num[i];++i)
	    sum += num[i]-'0';
	i=0;
	if(sum<10){
	       ++c;
	       goto asd;
	}
	while(sum){
	       num[i]=sum%10;
	       sum/=10;
	       i++;
	}
	num[i]='\0';
	++c;
	goto qer;
	asd:
	printf("%d",c);
	return 0;
}


//Bismillahir rahmanir rahim

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void) {
	// your code goes here
	char num[100001];
	gets(num);
	int i,c=0, y,sum=0;
	y = strlen(num);
	if(y<2){
	    goto asd;
	}
	qer:
	for(i=0;num[i];++i)
	    sum += num[i]-'0';
	//printf("%d\n",sum);
	i=0;
	if(sum<10){
	       ++c;
	       goto asd;
	}
	while(sum){
	       num[i]=sum%10+'0';
	       sum/=10;
	       i++;
	}
	num[i]='\0';
	++c;
	goto qer;
	asd:
	printf("%d",c);
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    char arr[100002];
    int sum=0,c=0,i,j,k,l;
    scanf("%s",arr);
    l=strlen(arr);
    if(l!=1)
    {
       for(i=0;i<l;i++)
        sum=sum+arr[i]-48;
        c++;
    }
    while(sum>=10)
    {
        k=0;
        while(sum!=0)
        {
            j=sum%10;
            k+=j;
            sum/=10;
        }
        sum=k;
        c++;
    }
    printf("%d",c);
    return(0);

}


#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
int n,i,j,sum=0,count=0;char no[100002];

    scanf("%s",&no);
    while(no[1])
    {
        count++;
        int sum=0;
        for(j=0;no[j];j++)sum+=no[j]-'0';
        sprintf(no,"%d",sum);
    }
    printf("%d",count);
return 0;
}


#include<stdio.h>
#include<string.h>
#define LENGTH 100001

int main(void){
  int count[10];
  char num[LENGTH];
  int i,j,k,l,times=0,sum;
  scanf("%s",num);
  for(i=0;i<10;i++) count[i]=0;
  l=strlen(num);
  if(l==1){
    puts("0");
    return 0;
  }

  for(i=0;i<l;i++) count[num[i]-'0']++;
  times=1;
  while(1){
    for(i=0,k=0;i<10;i++) k+=count[i];
    if(k<=1) break;
    for(i=0,sum=0;i<10;i++) sum+=i*count[i];
    sprintf(num,"%d\0",sum);
    l=strlen(num);
    for(i=0;i<10;i++) count[i]=0;
    for(i=0;i<l;i++) count[num[i]-'0']++;
    times++;
  }
  printf("%d\n",times-1);
  return 0;
}


#include<stdio.h>
#include<string.h>
char a[100009];
int main()
{

    int n,m=0,i,j,len,count=1,m1;
    gets(a);
    len=strlen(a);
    if(len==1)
    {
        printf("0");
        return 0;
    }
    for(i=0;i<len;i++)
        m+=(a[i]-48);
        m1=m;
        //printf("%d ",m);
    while(1)
    {
        if(m1/10==0)
            break;
        else
        {
            m=0;
            count++;
            while(m1)
            {
                m+=m1%10;
                m1/=10;
            }
            m1=m;
        }

    }
    printf("%d",count);
}


int main()
{
    char digits[100001];
    scanf("%s", digits);

    int nbr=0;
    if (digits[1] != 0)
    {
        int digitsum=0;
        char* p = digits;
        while (*p != 0)
        {
            digitsum += (*p - '0');
            ++p;
        }
        ++nbr;

        while (digitsum > 9)
        {
            int m=digitsum;
            digitsum = 0;
            while (m != 0)
            {
                digitsum += m % 10;
                m /= 10;
            }
            ++nbr;
        }
    }
    printf("%d\n", nbr);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
    char ch[100002];
    scanf("%s",ch);
    int n=0,i,j=0;
    for(i=0;ch[i];i++)
    {
        n+=ch[i]-'0';
    }
    int m=0;
    if(!n||i==1)
    {
        printf("%d",0);
        return 0;
    }
    j++;
    l1:
    if(n>9)
    {
        j++;
        while(n)
        {
            m+=n%10;
            n=n/10;
        }
        n^=m;
        m^=n;
        n^=m;
        goto l1;
    }
    printf("%d",j);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
    char ch[100002];
    scanf("%s",ch);
    int n=0,i,j=0;
    for(i=0;ch[i];i++)
    {
        n+=ch[i]-'0';
    }
    int m=0;
    if(n<10)
    {
        printf("%d",0);
        return 0;
    }
    j++;
    l1:
    if(n>9)
    {
        j++;
        while(n)
        {
            m+=n%10;
            n=n/10;
        }
        n^=m;
        m^=n;
        n^=m;
        goto l1;
    }
    printf("%d",j);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
    char ch[100002];
    scanf("%s",ch);
    int n=0,i,j=0;
    for(i=0;ch[i];i++)
    {
        n+=ch[i]-'0';
    }
    int m=0;
    if(!n)
    {
        printf("%d",0);
        return 0;
    }
    j++;
    l1:
    if(n>9)
    {
        j++;
        while(n)
        {
            m+=n%10;
            n=n/10;
        }
        n^=m;
        m^=n;
        n^=m;
        goto l1;
    }
    printf("%d",j);
    return 0;
}


#include<stdio.h>
#include<string.h>
#define MAX 100000
int strsum(char *s)
{
   int ans=0;
   while(*s){
      ans+=*s-'0';
      s++;
   }
   return ans;
}
int main()
{
   int ans,in,out;
   char inchar[MAX+1];
   scanf("%s",inchar);
   if(inchar[1]=='\0')
      printf("0\n");
   else{
      ans=1;
      in=strsum(inchar);
      while(in>9){
         out=0;
         while(in){
            out+=in%10;
            in/=10;
         }
         ans++;
         in=out;
      }
      printf("%d\n",ans);
   }
   return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
     char s[100005];
     int n = 1, sum = 0, i;

     scanf("%s", s);

     if (strlen(s) == 1) {
	  puts("0");

	  return 0;
     }

     for (i = 0; i < strlen(s); i++) sum += s[i] - '0';

     while (sum / 10 > 0) {
	  int p = 0;

	  while (sum) {
	       p += sum % 10;
	       sum /= 10;
	  }

	  sum = p;
	  n++;
     }

     printf("%d\n", n);

     return 0;
}


#include <stdio.h>

int conv(char *inp) {
    int n = 0;
    while (*inp) {
        n += *inp - '0';
        inp++;
    }

    return n;
}

int nsum(int n) {
    int sum = 0;
    while (n) {
        sum += (n % 10);
        n /= 10;
    }

    return sum;
}

int main(void) {
    int n = 0, cnt = 0;
    char inp[100002] = {0, };

    scanf("%s", inp);

    if (inp[1] != 0) {
        n = conv(inp);
        cnt++;
        while (n >= 10) {
            n = nsum(n);
            cnt++;
        }
    }

    printf("%d\n", cnt);

    return 0;
}


#include <stdio.h>
#include <string.h>
char s[100009];
int main()
{
  scanf("%s", s);
  int n = 0, res = 0, i;
  if (strlen(s) < 2) {
    printf("0\n");
    return 0;
  }
  while (1) {
    res++;
    int n = 0;
    for (i = 0; i < strlen(s); i++) {
      n += s[i] - '0';
    }
    if (n <= 9) break;
    sprintf(s, "%d", n);
  }
  printf("%d\n", res);
  return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
int n,i,j=0,a,sum=0;
char str[100000];
scanf("%s",str);
//while(sum>=10){
if(atoi(str)<10)
    printf("0");
else{
for(j=1;j<=1000000000;j++){
        sum=0;
for(i=0;i<=strlen(str)-1;i++){
        a=str[i]-'0';
    sum=sum+a;
}
if(sum<10)
    break;
sprintf(str,"%d",sum);
//printf("%s ",str);
}

printf("%d",j);
}
return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
int n,i,j=0,a,sum=0;
char str[100000];
scanf("%s",str);
//while(sum>=10){
if(strlen(str)==1)
    printf("0");
else{
for(j=1;j<=1000000000;j++){
        sum=0;
for(i=0;i<=strlen(str)-1;i++){
        a=str[i]-'0';
    sum=sum+a;
}
if(sum<10)
    break;
sprintf(str,"%d",sum);
//printf("%s ",str);
}

printf("%d",j);
}
return 0;
}


#include<stdio.h>
#include<string.h>
main()
{
      int i=0,j,k,total=0,c;
      char a[100005];
      scanf("%s",a);
      for(i=0;i<strlen(a);i++)
      {
            total+=(a[i]-'0');
      }
      if(total==0){j=-1;goto x;}
      for(j=0;total/10!=0;j++)
           {
            c=0;
            for(k=0;total!=0;k++)
            {
                c+=total%10;
                total/=10;
            }
        total=c;
           }
           x:
      printf("%d",j+1);
      return 0;
}


#include<stdio.h>
#include<string.h>
main()
{
      int i=0,j,k,total=0,c;
      char a[100005];
      scanf("%s",a);
      for(i=0;i<strlen(a);i++)
      {
            total+=(a[i]-'0');
      }
      if(strlen(a)==1){j=-1;goto x;}
      for(j=0;total/10!=0;j++)
           {
            c=0;
            for(k=0;total!=0;k++)
            {
                c+=total%10;
                total/=10;
            }
        total=c;
           }
           x:
      printf("%d",j+1);
      return 0;
}


#include<stdio.h>
#include<string.h>
main()
{
      int i=0,j,k,total=0,c;
      char a[100005];
      scanf("%s",a);
      for(i=0;i<strlen(a);i++)
      {
            total+=(a[i]-'0');
      }
      if(total/10==0){j=-1;goto x;}
      for(j=0;total/10!=0;j++)
           {
            c=0;
            for(k=0;total!=0;k++)
            {
                c+=total%10;
                total/=10;
            }
        total=c;
           }
           x:
      printf("%d",j+1);
      return 0;
}


#include<stdio.h>

int main () {

        char n[100000];
        int i=0,sum=0,count=0,j,k,l;
        scanf("%s",n);

        while(n[i]!=0) {
                sum+=n[i]-48;
                i++;
        }
        if(sum>9)
                count++;
        k=sum;
        while(k>9) {
                l=0;
                while(k!=0) {
                        j=k%10;
                        l+=j;
                        k/=10;
                }
                k=l;
                count++;
        }
        if((n[1]!=0)&&(sum<10))
                count++;
        printf("%d",count);
        return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
char s[100100];
int cnt,n,i,t,l;
scanf("%s",s);
l=strlen(s);

if(l==1) {printf("0");return 0;}
n=0;
for(i=0;i<l;i++)
n+=s[i]-'0';

cnt=1;
while(n/10!=0)
{
t=0;
while(n!=0)
{
t+=n%10;
n=n/10;
}
n=t;
cnt++;
}

printf("%d\n",cnt);

return 0;
}


#include <stdio.h>

int main (){
	char a;
	int count = 0;
	int count2 = 0;
	int res = 0;
	int res2 = 0;
	int res3 = 0;
	while (a != '\n'){
		scanf ("%c", &a);
		res = res + (int)(a-'0');
		count2++;
	}
	res = res + 38;
	if (count2 >= 3)
		count++;
	while (res/10 != 0){
		res2 = res;
		while (res2 != 0){
			res3 = res3 + res2%10;
			res2 = res2 / 10;
		}
		res = res3;
		res3 = 0;
		count++;
	}
	printf ("%i\n", count);
	return 0;
}


#include <stdio.h>
#include <string.h>

char s[100005 ] , a, b  ;

int n , i , j , k , sum , q , t[100001] ;

int digit_count( int p )
{
    if ( p == 0 ) return 0 ;
    return 1 + digit_count( p / 10 ) ;
}

int digit_sum( int m )
{
    if ( m == 0) return 0 ;

    return m%10 + digit_sum(m / 10 ) ;

}

int main()
{
    scanf("%s" , s) ;
    n = strlen(s) ;

    if ( n == 1 ) printf("0 ") ;

    else
    {

        for ( i = 0 ; i < n ; i++) sum += s[i] - '0' ;

        k = 1 ;

        while ( 1 != digit_count( sum ) )
        {
            sum = digit_sum(sum ) ;
            k++ ;

           // printf("sum = %d\n", sum ) ;
        }

        printf("%d", k ) ;

       }
return 0 ;
}


#include <stdio.h>
#include <string.h>

char s[1000001];

void func()
{
    int n = 0, m, ans, len = strlen(s), i;
    if (len == 1)
    {
        printf("0\n");
        return;
    }
    for (i = 0; i < len; i++)
    {
        n += (s[i] - '0');
    }
    ans = 1;
    while (n / 10 != 0)
    {
        m = 0;
        while (n)
        {
            m += n % 10;
            n /= 10;
        }
        ans++;
        n = m;
    }
    printf("%d\n", ans);
}

int main(int argc, char **argv)
{
    while (scanf("%s", s) == 1)
    {
        func();
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
unsigned int sum_digits(char *array, int length)
{
	int i, sum = 0;
	for(i = 0; i < length; i++)
	{
		sum += array[i];
	}
	return sum;
}
char *mkarray(unsigned int n)
{
	unsigned int temp = n;
	int len = 0;
	while(temp > 0)
	{
		temp /= 10;
		len ++;
	}
	char *array = (char *)malloc(sizeof(unsigned int) * len);
	unsigned int i = 0;
	while(n > 0)
	{
		array[i] = (char)(n % 10);
		n /= 10;
		i++;
	}
	return array;
}
int main()
{
	char *s = (char *)malloc(sizeof(char) * 100002);
	scanf("%s", s);
	char *p = s;
	int sum = 0;
	int len = 0;
	while(*p != '\0')
	{
		*p = *p - '0';
		p ++;
		len ++;
	}
	int time = 0;
	if(len > 1)
	{
		do
		{
			time ++;
			sum = sum_digits(s, len);
			free(s);
			s = mkarray(sum);
		} while(sum >= 10);
	}
	printf("%d\n", time);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
unsigned int sum_digits(char *array, int length)
{
	int i, sum = 0;
	for(i = 0; i < length; i++)
	{
		sum += array[i];
	}
	return sum;
}
char *mkarray(unsigned int n, int *length)
{
	unsigned int temp = n;
	int len = 0;
	while(temp > 0)
	{
		temp /= 10;
		len ++;
	}
	char *array = (char *)malloc(sizeof(unsigned int) * len);
	*length = len;
	unsigned int i = 0;
	while(n > 0)
	{
		array[i] = (char)(n % 10);
		n /= 10;
		i++;
	}
	return array;
}
int main()
{
	char *s = (char *)malloc(sizeof(char) * 100002);
	scanf("%s", s);
	char *p = s;
	int sum = 0;
	int len = 0;
	while(*p != '\0')
	{
		*p = *p - '0';
		p ++;
		len ++;
	}
	int time = 0;
	if(len > 1)
	{
		do
		{
			time ++;
			sum = sum_digits(s, len);
			free(s);
			s = mkarray(sum, &len);
		} while(sum >= 10);
	}
	printf("%d\n", time);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
unsigned int sum_digits(char *array, int length)
{
	int i, sum = 0;
	for(i = 0; i < length; i++)
	{
		sum += array[i];
	}
	return sum;
}

char *mkarray(unsigned int n)
{
	unsigned int temp = n;
	int len = 0;
	while(temp > 0)
	{
		temp /= 10;
		len ++;
	}
	char *array = (char *)malloc(sizeof(unsigned int) * len);
	unsigned int i = 0;
	while(n > 0)
	{
		array[i] = (char)(n % 10);
		n /= 10;
		i++;
	}
	return array;
}
int main()
{
	char *s = (char *)malloc(sizeof(char) * 100002);
	scanf("%s", s);
	char *p = s;
	int sum = 0;
	int len = 0;
	while(*p != '\0')
	{
		*p = *p - '0';
		p ++;
		len ++;
	}
	int time = 0;
	if(len > 1)
	{
		do
		{
			time ++;
			sum = sum_digits(s, len);
			free(s);
			s = mkarray(sum);
		} while(sum >= 10);
	}
	printf("%d\n", time);
	return 0;
}


#include<stdio.h>
int main()
{
	int n;
	int sum=0, m, t=0;

	while(scanf("%d",&n)!=EOF)
	{
		if(n==0)
			t=0;
		else
		{
			while(n!=0)
			{
				m=n%10;
				n=n/10;
				sum=sum+m;
				if(n==0)
					t++;
				if(n==0&&sum>=10)
				{
					n=sum;
					sum=0;
				}
				else if(sum<10&&n==0)
					break;
			}
		}
	}
	printf("%d\n",t);

	return 0;
}


#include<stdio.h>

#include<string.h>
void main()
{
	int a,b,c,d,e,f;
	char x[100000];
	while(scanf("%s",x)!=EOF)
	{
		c=0;
		a=strlen(x);
		if(a<=1)
			printf("0\n");
		else
		{
		for(b=0;b<a;b++)
			c+=int(x[b])-48;
		for(f=1;c>=10;f++)
		{
			e=0;
		for(d=c;d>0;d/=10)
		{
			e+=d%10;
		}
		c=e;
		}
		printf("%d\n",f);
		}
	}
}


#include<stdio.h>
int main(void)
{
	int i=0,n,sum=0,sum1=0,sum2=0;
	scanf("%d",&n);
	while(n>0)
	{
		sum+=n%10;
		n=n/10;
	}
	i++;
	if(sum<10)
		printf("%d\n",i);
	else if(sum>=10)
	{
		while(sum>0)
		{
			sum1+=sum%10;
			sum=sum/10;
		}
	    i++;
	    if(sum1<10)
		    printf("%d\n",i);
	    else if(sum1>=10)
	    {
		while(sum1>0)
		 {
			sum2+=sum1%10;
			sum1=sum1/10;
		 }
	    i++;
	    if(sum2<10)
           printf("%d\n",i);
		}
	}
}


#include<stdio.h>
int main(void){
char c[100005];
int i,sum,count;
i=0;
sum=0;
count=0;
while(1){
scanf("%c",&c[i]);
if(c[i]=='\n')break;
sum+=c[i]-'0';
i++;
}
//printf("%d\n",sum);
if(sum==0){printf("0");return 0;}
if(sum>10)count++;
while(sum>=10){
int temp=0;
while(sum>0){
temp+=sum%10;
sum/=10;
}
sum=temp;
count++;
}
printf("%d",count);
return 0;
}


#include<stdio.h>
int main()
{
	int n;
	int sum=0, m, t=0;

	scanf("%d",&n);
	if(n==0)
		t=0;
	else
	{
		while(n!=0)
		{
			m=n%10;
			n=n/10;
			sum=sum+m;
			if(n==0)
				t++;
			if(n==0&&sum>=10)
			{
				n=sum;
				sum=0;
			}
			else if(sum<10&&n==0)
				break;
		}
	}

	printf("%d",t);

	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include<set>
#include <algorithm>
using namespace std;

char s[100100];

int main()
{
    int n,cnt,i,res;
    scanf("%s",s);
    cnt=0;
    while (s[1])
    {
        cnt++;
        res=0;
        for(i=0;s[i];i++)
        {
            res+=s[i]-'0';
        }
        sprintf(s,"%d",res);
    }
    printf("%d\n",cnt);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int DR(int a)
{
int result = 0;
while (a > 0)
{
result += a%10;
 a /= 10;
}
return result;
}

int main()
{
int n=0;
scanf("%d", &n);
{
int result = n;
int j=0;
while (result >= 10)
{
result = DR(result);
j++;
}

printf("%d\n",j );
}
return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	char s[1000100];
	int slen, i, j = 0, sum = 0,x = 0;
	while (scanf("%s",s)!=EOF)
	{

		slen = strlen(s);
		for (i = 0; i < slen; ++i)
		{
			sum += s[i] - '0';
		}
		if (sum != 0)
			x += 1;
		if (sum > 9)
		{
			while (sum != 0)
			{
				j += sum % 10;
				sum /= 10;
				if (sum == 0)
					x += 1;
				if (j > 9 && sum == 0)
				{
					sum = j;
					j = 0;
				}
			}
		}
		printf("%d\n", x);
		j = 0; sum = 0; x = 0;

	}
	return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
char a;
int t=0,i=1,sum=0;
scanf("%c",&a);
while(a!='\n'){
    i++;
    sum+=a-'0';
    scanf("%c",&a);
}
if(i!=1){
if(sum){
    t++;
int s;
while(sum){
    s=0;
if(sum<10)
    break;
while(sum){
    s+=sum%10;
    sum/=10;
}
sum=s;
    t++;
}
}
}
printf("%d\n",t);
return 0;
}


#include <stdio.h>
char s[100100];

int main()
{
    int n,cnt,i,res;
    scanf("%s",s);
    cnt=0;
    while (s[1])
    {
        cnt++;
        res=0;
        for(i=0;s[i];i++)
            res+=s[i]-'0';
        sprintf(s,"%d",res);
    }
    printf("%d\n",cnt);
    return 0;
}


#include <stdio.h>
int main()
{
	char s[111111];
    int m,i,res;
    scanf("%s",s);
    m=0;
    while (s[1])
    {
        m++;
        res=0;
        for(i=0;s[i];i++)
            res+=s[i]-'0';
        sprintf(s,"%d",res);
    }
    printf("%d",m);
    return 0;
}


#include<stdio.h>
#include<string.h>
	char s[1000000];

int g(int a)
{
	int z=0;
	while(1)
	{
		z+=a%10;
		a=a/10;
		if(a==0)
			return z;
	}
}
int main()
{

	scanf("%s",&s);
	int len=strlen(s);
	int x=0;
	if(len==1)
	{
		printf("0\n");
		return 0;
	}

	for(int i=0;i<len;i++)
	{
		x=x+s[i]-'0';
	}
	int ans=1;
	while(x>9)
	{
		ans++;
		x=g(x);
	}
	printf("%d\n",ans);

}


#include<stdio.h>
int main(void){
char c[100005];
int i,sum,count;
i=0;
sum=0;
count=0;
while(1){
scanf("%c",&c[i]);
if(c[i]=='\n')break;
sum+=c[i]-'0';
i++;
}
//printf("%d\n",sum);
if(sum==0){printf("0");return 0;}

count++;
while(sum>=10){
int temp=0;
while(sum>0){
temp+=sum%10;
sum/=10;
}
sum=temp;
count++;
}
printf("%d",count);
return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int fun(char a)
{
	if(a=='1') return 1;
	if(a=='2') return 2;
	if(a=='3') return 3;
	if(a=='4') return 4;
	if(a=='5') return 5;
	if(a=='6') return 6;
	if(a=='7') return 7;
	if(a=='8') return 8;
	if(a=='9') return 9;
	if(a=='0') return 0;
}
void main()
{
	char p[999999];
	int i,n,t,a,b,c;
	while(scanf("%s",p)!=EOF)
	{
		if(strcmp(p,"0")==0)
			a=0;
		else
		{
	a=1;
	t=0;
	n=strlen(p);
	for(i=0;i<n;++i)
		t=fun(p[i])+t;
	while(t>=10)
	{
		c=0;
		b=t;
		for(i=1;i<=10;++i)
		{
		    c=b%10+c;
		    b=b/10;
		}
		t=c;
		++a;
	}
		}
	printf("%d\n",a);
	}
}


#include<stdio.h>

#include<stdlib.h>

int main()

{

        char integer[100];

        int value = 0,temp_value = 0,sum = 0;

        gets(integer);

        value = atoi(integer);

        temp_value = value;

        while(value >= 1)

        {

                sum += value%10;

                value = value / 10;

        }

        printf("the integer is %d and the sum of decimal digits is %d \n",temp_value,sum);

        return 0;

}


#include<stdio.h>
#include<string.h>
int main(){
char a;
int t=0,i,sum=0;
scanf("%c",&a);
while(a!='\n'){
    sum+=a-'0';
    scanf("%c",&a);
}
if(sum>9){
    t++;
int s;
while(sum){
    s=0;
if(sum<10)
    break;
while(sum){
    s+=sum%10;
    sum/=10;
}
sum=s;
    t++;
}
}
printf("%d\n",t);
return 0;
}


#include<stdio.h>
#include<string.h>
char s[100100];

int main()
{
    int n,cnt,i,res;
    scanf("%s",s);
    cnt=0;
    while (s[1])
    {
        cnt++;
        res=0;
        for(i=0;s[i];i++)
        {
            res+=s[i]-'0';
        }
        sprintf(s,"%d",res);
    }
    printf("%d\n",cnt);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    char str[100002];
    int n,l=0,count=0,sum=0,i;
    scanf("%s",str);
    n=strlen(str);
    while(n!=1)
    {
        for(i=0;str[i]!='\0';i++)
        {
            sum=sum+str[i]-'0';
        }
        l=0;
        while(sum)
        {
            if(sum%10==0)
            {
                str[l++]=48;sum=sum/10;
            }
            else
            {
                str[l++]=(sum%10)+48;
                sum=sum/10;
            }
           str[l]='\0';
        }
         n=strlen(str);
            count++;
        sum=0;
    }
    printf("%d",count);
}


#include<stdio.h>
#include<string.h>

int main()
{
	int i, j, k, sum=100;
	char ar[100001];
	scanf("%s", &ar);
	int ans=0;
	int len = strlen(ar);
	if(len<2)
		printf("0");
	else
	{
		ans=0;k=0;
		for(i=0;i<len;i++)
			k = k+ar[i]-'0';
		ans++;
		//printf("k=%d\n", k);
		if(k<10)
			printf("1");
		else
		{
			sum=k;
			//printf("%d\n", sum);
			while(sum>=10)
			{
				sum=0;
				j=k;
				while(j>0)
				{
					sum+=j%10;
					j/=10;
				}
				ans++;
				k = sum;
			}
			printf("%d", ans);
		}
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
char s[100100];
int cnt,n,i,t,a;
scanf("%s",s);
a=strlen(s);

if(a==1) {printf("0");return 0;}
n=0;
for(i=0;i<a;i++)
n+=s[i]-'0';

cnt=1;
while(n/10!=0)
{
t=0;
while(n!=0)
{
t+=n%10;
n=n/10;
}
n=t;
cnt++;
}

printf("%d\n",cnt);

return 0;
}


#include<stdio.h>
#include<string.h>

int main(void)
{
	int n,cnt,sum,len,i;
	char s[100001];

	scanf("%s" ,s);
	n=0;
	len=strlen(s);
	if(len<=1)	printf("0\n");
	else{
		for(i=0;i<len;i++)	n+=s[i]-'0';
		cnt=1;
		while(n>=10){
			sum=0;
			while(n>=10){
				sum+=n%10;
				n/=10;
			}
			sum+=n%10;
			n=sum;
			cnt++;
		}
		printf("%d\n" ,cnt);
	}
	return 0;
}


#include<stdio.h>

int main(void)
{
	int n,cnt,sum;

	scanf("%d" ,&n);
	cnt=0;
	while(n>=10){
		sum=0;
		while(n>=10){
			sum+=n%10;
			n/=10;
		}
		sum+=n%10;
		n=sum;
		cnt++;
	}
	printf("%d\n" ,cnt);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
    char ara[100005];
    long long s, p = 0, i;
    scanf("%s", ara);
    if(strlen(ara) > 1)
         p = 1;
    while(1)    {
        s = 0;
        for(i = 0; i < strlen(ara); i++)    {
            s = s + ara[i] - '0';
        }
        if(s > 9)    {
            itoa(s , ara , 10);
            p++;
        }
        else    {
            break;
        }
    }
    printf("%d\n", p);
    return 0;
}


#include <stdio.h>

int n;
int sum = 0;

void sumDigits(void) {
  sum = 0;
  while(n > 0) {
    sum += n%10;
    n -= n%10;
    n /=10;
  }
  n = sum;
}

main() {
  scanf("%d", &n);

  int count = 0;

  while(n > 9) {
    sumDigits();
    count++;
  }

  printf("%d", count);

  exit(0);
}


#include <stdio.h>

int sumDigits(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n%10;
    n -= n%10;
    n /=10;
  }
  return sum;
}

main() {
  long n;

  scanf("%ld", &n);

  int count = 0;

  while(n > 9) {
    n = sumDigits(n);
    count++;
  }

  printf("%d", count);

  exit(0);
}


#include <stdio.h>

int sumDigits(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n%10;
    n -= n%10;
    n /=10;
  }
  return sum;
}

main() {
  int n;

  scanf("%d", &n);

  int count = 0;

  while(n > 9) {
    n = sumDigits(n);
    count++;
  }

  printf("%d", count);

  exit(0);
}


#include <stdio.h>
#include <math.h>
#include <string.h>

int sumDigits(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n%10;
    n -= n%10;
    n /=10;
  }
  return sum;
}

main() {
  char buffer[100000];
  int i;
  int n = 0;
  int count = 0;

  gets(buffer);
  int len = strlen(buffer);

  int exp = 0;
  for(i = 0; i < len; i++) {
    n += (buffer[i] - '0')*pow(10, exp);
    exp++;
  }

  if(n == 0) {
    printf("0");
  exit(0);
  }

  else if(n >= 1 && n <= 9) {
    printf("1");
    exit(0);
   }

  while(n > 9) {
    n = sumDigits(n);
    count++;
  }

  printf("%d", count);

  exit(0);
}


#include <stdio.h>
#include <math.h>
#include <string.h>

int sumDigits(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n%10;
    n -= n%10;
    n /=10;
  }
  return sum;
}

main() {
  char buffer[100000];
  int i;
  int n = 0;
  int count = 0;

  gets(buffer);
  int len = strlen(buffer);

  //special case: n is a 1 digit number
  if(len < 2) {
    printf("%d", count);
    exit(0);
  }

  count = 1;

  for(i = 0; i < len; i++)
    n += buffer[i] - '0';

  while(n > 9) {
    n = sumDigits(n);
    count++;
  }

  printf("%d", count);

  exit(0);
}


#include <stdio.h>
#include <math.h>
#include <string.h>

int sumDigits(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n%10;
    n -= n%10;
    n /=10;
  }
  return sum;
}

main() {
  char buffer[100005];
  int i;
  int n = 0;
  int count = 0;

  gets(buffer);
  int len = strlen(buffer);

  int exp = 0;
  for(i = 0; i < len; i++) {
    n += (buffer[i] - '0')*pow(10, exp);
    exp++;
  }

  if(n == 0) {
    printf("0");
  exit(0);
  }

  else if(n >= 1 && n <= 9) {
    printf("1");
    exit(0);
   }

  while(n > 9) {
    n = sumDigits(n);
    count++;
  }

  printf("%d", count);

  exit(0);
}


#include <stdio.h>
#include <math.h>
#include <string.h>

int sumDigits(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n%10;
    n -= n%10;
    n /=10;
  }
  return sum;
}

main() {
  char buffer[100006];
  int i;
  int n = 0;
  int count = 0;

  gets(buffer);
  int len = strlen(buffer);

  int exp = 0;
  for(i = 0; i < len; i++) {
    n += (buffer[i] - '0')*pow(10, exp);
    exp++;
  }

  if(n == 0) {
    printf("0");
  exit(0);
  }

  else if(n >= 1 && n <= 9) {
    printf("1");
    exit(0);
   }

  while(n > 9) {
    n = sumDigits(n);
    count++;
  }

  printf("%d", count);

  exit(0);
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX_LEN 100010

int main (int argc, char *argv[]){

    char n[MAX_LEN];
    scanf("%s", n);

    int i=0, times=0, sum;

    int len = strlen(n);

    while (len > 1){
        sum=0, i=0;
        while (i<len){
            sum += (n[i] - '0');
            i++;
        }
        sprintf(n, "%d", sum);
        //printf("+%d\n", sum);
        times++;
        len = strlen(n);
    }
    printf("%d\n", times);

    return EXIT_SUCCESS;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
    char n[100000];
    long long s, p = 0, i;
    scanf("%s", &n);
    if(strlen(n) > 1)
         p = 1;
start:   s = 0;
    for(i = 0; i < strlen(n); i++)
         s = s + n[i] - '0';
    if(s > 9)
    {
         itoa(s , n , 10);
         p++;
         goto start;
    }
    printf("%d", p);
    system("Pause");
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
    char n[100000];
    long long s, p = 0, i;
    scanf("%s", &n);
    if(strlen(n) > 1)
         p = 1;
start:   s = 0;
    for(i = 0; i < strlen(n); i++)
         s = s + n[i] - '0';
    if(s > 9)
    {
         itoa(s , n , 10);
         p++;
         goto start;
    }
    printf("%d", p);
    return 0;
}


#include <stdio.h>

int main()
{
    char c='e';
    long sum=0;
    int so;

    int count = 0;
    while (c!='\n')
    {
          count++;
          so = 0;
          scanf("%c",&c);
          if (c=='\n')
             break;
          so = c - 48;

          sum = sum + so;

    }

    if (count > 2)
       count = 1;
    else
        count = 0;

    long s = 0;
    long t = 0;
    int m;
    while (sum > 9)
    {
          t = sum;
          s= 0;
          while (t>0)
          {
                m = t % 10;
                s = s + m;
                t=t/10;
          }
          count++;
          sum = s;
    }

    printf("%d\n", count);
    return 0;
}


#include <stdio.h>

int main()
{
    char c='e';
    long sum=0;
    int so;

    int count = 0;
    while (c!='\n')
    {
          count++;
          so = 0;
          scanf("%c",&c);
          if (c=='\n')
             break;
          so = int(c) - 48;

          sum = sum + so;

    }

    if (count > 2)
       count = 1;
    else
        count = 0;

    long s = 0;
    long t = 0;
    int m;
    while (sum > 9)
    {
          t = sum;
          s= 0;
          while (t>0)
          {
                m = t % 10;
                s = s + m;
                t=t/10;
          }
          count++;
          sum = s;
    }

    printf("%d\n", count);

}


#include <stdio.h>

void main()
{
    char c='e';
    long sum=0;
    int so;

    int count = 0;
    while (c!='\n')
    {
          count++;
          so = 0;
          scanf("%c",&c);
          if (c=='\n')
             break;
          so = int(c) - 48;

          sum = sum + so;

    }

    if (count > 2)
       count = 1;
    else
        count = 0;

    long s = 0;
    long t = 0;
    int m;
    while (sum > 9)
    {
          t = sum;
          s= 0;
          while (t>0)
          {
                m = t % 10;
                s = s + m;
                t=t/10;
          }
          count++;
          sum = s;
    }

    printf("%d\n", count);

}


#include <stdio.h>
#include <stdlib.h>

char Str[100001];

int main()
{
    int i,Sum,Cnt;
    scanf("%s",Str);
    if(Str[1]=='\0')
    {
        puts("0");
        return 0;
    }
    for(Cnt=1,Sum=i=0; Str[i]!='\0'; ++i)
    {
        Sum+=Str[i]-'0';
    }
    while(Sum>9)
    {
        itoa(Sum,Str,10);
        for(Sum=i=0; Str[i]!='\0'; ++i)
        {
            Sum+=Str[i]-'0';
        }
        ++Cnt;
    }
    printf("%d\n",Cnt);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

char Str[100001];

int main()
{
    int i,Sum;
    scanf("%s",Str);
    for(Sum=i=0; Str[i]!='\0'; ++i)
    {
        Sum+=Str[i]-'0';
    }
    while(Sum>9)
    {
        itoa(Sum,Str,10);
        for(Sum=i=0; Str[i]!='\0'; ++i)
        {
            Sum+=Str[i]-'0';
        }
    }
    printf("%d\n",Sum);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

char Str[100001];

int main()
{
    int i,Sum,Cnt;
    scanf("%s",Str);
    for(Cnt=Sum=i=0; Str[i]!='\0'; ++i)
    {
        Sum+=Str[i]-'0';
    }
    while(Sum>9)
    {
        itoa(Sum,Str,10);
        for(Sum=i=0; Str[i]!='\0'; ++i)
        {
            Sum+=Str[i]-'0';
        }
        ++Cnt;
    }
    printf("%d\n",Cnt);
    return 0;
}


#include<stdio.h>
int main()
{
    long long int i=0,j,k,l,m,n,sum=0;
    scanf("%lld",&n);
    while(n>9)
    {
        sum=0;
        j=n;
        while(j!=0)
        {
            sum=sum+j%10;
            j=j/10;
        }

        n=sum;
        i++;
    }
    printf("%lld",i);
    return 0;
}


#include<stdio.h>
long long int main()
{
    long long int i=0,j,k,l,m,n,sum=0;
    scanf("%lld",&n);
    while(n>9)
    {
        sum=0;
        j=n;
        while(j!=0)
        {
            sum=sum+j%10;
            j=j/10;
        }

        n=sum;
        i++;
    }
    printf("%lld",i);
    return 0;
}


#include<stdio.h>
int main()
{
    int i=0,j,k,l,m,n,sum,p;
    char a[100000];
    scanf("%s",a);
    for(i=0;a[i]!='\0';i++)
    {
        sum=sum+a[i]-'0';

    }
    if(i==1)
    p=0;
    else
    p=1;

    while(sum>9)
    {
    i=sum;
    sum=0;
    while(i>0)
    {
    sum=sum+i%10;
    i=i/10;
    }
    p++;
    }
    printf("%d",p);
    return 0;
}


#include<stdio.h>
int main()
{
    int i=0,j,k,l,m,n,sum=0;
    scanf("%d",&n);
    while(n>9)
    {
        sum=0;
        j=n;
        while(j!=0)
        {
            sum=sum+j%10;
            j=j/10;
        }

        n=sum;
        i++;
    }
    printf("%d",i);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define sz(a)int(a.size())

int vis [5010][30][30];
int c   [30][5010];

int main () {
	string s;
	cin >> s;

	int n = sz(s);

	for (int i = 0; i < n; i++) {
		int p = i;
		for (int j = 1; j < n; j++) {
			p++;
			if (p >= n) p = 0;
			vis[j][s[i]-'a'][s[p]]++;
		}
	}

	double ans = 0;

	for (int i = 0; i < n; i++) {
		int p = i;

		for (int j = 1; j < n; j++) {
			p++;
			if (p >= n) p = 0;
			if (vis[j][s[i]-'a'][s[p]] == 1) c[s[i]-'a'][j]++;
		}

	}

	for (int i = 0; i < 26; i++) {
		int mx = 0;
		for (int j = 1; j < n; j++) mx = max(mx, c[i][j]);
		ans += 1.0*mx/n;
	}
	printf("%0.7f\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
string s;
double ans;
int cnt[200];
vector <int> v[200];
int main()
{
    cin >>s;
    double n=s.size();
    for (int i=0;i<n;i++)
        v[s[i]].push_back(i);
    for (char i='a';i<='z';i++)
    {
        if (!v[i].empty())
        {
            int x=v[i][0];
            int y=0;
            for (int k=0;k<n;k++)
            {
                memset(cnt,0,sizeof cnt);
                for (int j=0;j<v[i].size();j++)
                {
                    v[i][j]++;
                    v[i][j]%=(int)n;
                    cnt[s[v[i][j]]]++;
                }
                int cur=0;
                for (int j='a';j<='z';j++)
                    cur+= (cnt[j]==1);
                y=max(y,cur);
            }
            ans+=y;
        }
    }
    cout <<fixed<<setprecision(8)<<(ans/n);
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<map>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<queue>
#include<vector>
#include<iomanip>
#include<string.h>
#include<algorithm>
#include<stack>
#include<complex>
#define inf 0x3f3f3f3f
#define pi (2*asin(1))
//std::ios::sync_with_stdio(false);
typedef long long ll;
using namespace std;
int ii[26][5005][26];
double t[26];
double p[26];
int main()
{
    int i,j,k,t1,t2,t3,n,m,sz;
    string s;
    cin>>s;
    sz=s.size();
    s+=s;
    memset(ii,0,sizeof(ii));
    memset(t,0,sizeof(t));
    memset(p,0,sizeof(p));
    for (i=0;i<sz;i++)
    {
        for (j=1;j<sz;j++)
            ii[s[i]-'a'][j][s[i+j]-'a']++;
        t[s[i]-'a']++;
    }
    int ans=0;
    for (i=0;i<26;i++)
    {
        int t2=0;
        for (j=1;j<sz;j++)
            {
                t1=0;
                for (k=0;k<26;k++)
                    t1+=(ii[i][j][k]==1);
                t2=max(t2,t1);
            }
        ans+=t2;
    }
    //cout<<ans<<' '<<s.size()<<endl;
    printf("%.7lf",(double)ans/(double)(sz));
}


#include<stdio.h>
#include<iostream>
#include<map>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<queue>
#include<vector>
#include<iomanip>
#include<string.h>
#include<algorithm>
#include<stack>
#include<complex>
#define inf 0x3f3f3f3f
#define pi (2*asin(1))
//std::ios::sync_with_stdio(false);
typedef long long ll;
using namespace std;
int time[26][5005][26];
double t[26];
double p[26];
int main()
{
    int i,j,k,t1,t2,t3,n,m,sz;
    string s;
    cin>>s;
    sz=s.size();
    s+=s;
    memset(time,0,sizeof(time));
    memset(t,0,sizeof(t));
    memset(p,0,sizeof(p));
    for (i=0;i<sz;i++)
    {
        for (j=1;j<sz;j++)
            time[s[i]-'a'][j][s[i+j]-'a']++;
        t[s[i]-'a']++;
    }
    int ans=0;
    for (i=0;i<26;i++)
    {
        int t2=0;
        for (j=1;j<sz;j++)
            {
                t1=0;
                for (k=0;k<26;k++)
                    t1+=(time[i][j][k]==1);
                t2=max(t2,t1);
            }
        ans+=t2;
    }
    //cout<<ans<<' '<<s.size()<<endl;
    printf("%.7lf",(double)ans/(double)(sz));
}


#include <bits/stdc++.h>
using namespace std;
#define PB push_back

#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <(b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define FORE(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;;
typedef vector<pair<int, int> > VPII;

bool  ch[26];
int is[26], a[5000], coun[26];
int32_t main() {

	ios_base::sync_with_stdio(0);
	cout << fixed << setprecision(10);
  	cerr << fixed << setprecision(10);
  	cin.tie(0);

	string s;
        cin >> s;
        int n = s.size();
        FOR(i, 0, n) {
            a[i] = s[i] - 'a';
        };
        int m = 0;
        FOR(c, 0, 26) {
            int mx = 0;
            FOR(s, 1, n) {
               vector<int> is(26, 0);
                FOR(i, 0, n) {
                    if(a[i] == c) is[a[(i + s) % n]]++;
                }
                int cur = 0;

                FOR(i, 0, 26) cur += (is[i] == 1);
                mx = max(mx, cur);

            }
            m += mx;
        }

        cout << 1.0 * m / n << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define PB push_back

#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <(b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define FORE(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;;
typedef vector<pair<int, int> > VPII;

bool  ch[26];
int is[26], a[5000], coun[26];
int32_t main() {

	ios_base::sync_with_stdio(0);
	cout << fixed << setprecision(10);
  	cerr << fixed << setprecision(10);
  	cin.tie(0);

	string s;
        cin >> s;
        int n = s.size();
        FOR(i, 0, n) {
            a[i] = s[i] - 'a';
        };
        int m = 0;
        FOR(c, 0, 26) {
            int mx = 0;
            FOR(s, 1, n) {
                memset(is,0, 26);
                FOR(i, 0, n) {
                    if(a[i] == c) is[a[(i + s) % n]]++;
                }
                int cur = 0;

                FOR(i, 0, 26) cur += (is[i] == 1);
                mx = max(mx, cur);

            }
            m += mx;
        }

        cout << 1.0 * m / n << endl;
	return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 5003
#define M 27
//int mod=1e9+7;
//int mod=998244353;
int cnt[M][N][M];       //states : current letter, distance, letter at that distance

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    memset(cnt,0,sizeof cnt);
    fill(freq,freq+M,0);
    string s;
    cin>>s;
    int i,dist,n=s.length();
    s+=s;
    for(i=0;i<n;++i)
    {
        for(dist=0;dist<=n-1;++dist)
        {
            cnt[s[i]-'a'][dist][s[i+dist]-'a']++;
        }
    }

    d ans=0;
    int ms,cs;
    for(char c='a';c<='z';++c)
    {
        ms=0;
        for(i=0;i<n;++i)              //you need to keep the distance constant( coz you have got just one guess) and get max letters distinguishable from it
        {
            cs=0;
            for(char ch='a';ch<='z';++ch)
            {
                cs+=(cnt[c-'a'][i][ch-'a']==1);
            }
            ms=max(ms,cs);
        }
        ans+=ms;
 //       cout<<"char(1st state) : "<<c<<" , ans : "<<ans<<"\n";
    }

    cout<<fixed<<setprecision(20)<<(ans/(d)n);

    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 5003
#define M 27
//int mod=1e9+7;
//int mod=998244353;
int cnt[M][N][M];       //states : current letter, distance, letter at that distance

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    memset(cnt,0,sizeof cnt);
    string s;
    cin>>s;
    int i,dist,n=s.length();
    s+=s;
    for(i=0;i<n;++i)
    {
        for(dist=0;dist<=n-1;++dist)
        {
            cnt[s[i]-'a'][dist][s[i+dist]-'a']++;
        }
    }

    d ans=0;
    int ms,cs;
    for(char c='a';c<='z';++c)
    {
        ms=0;
        for(i=0;i<n;++i)              //you need to keep the distance constant( coz you have got just one guess) and get max letters distinguishable from it
        {
            cs=0;
            for(char ch='a';ch<='z';++ch)
            {
                cs+=(cnt[c-'a'][i][ch-'a']==1);
            }
            ms=max(ms,cs);
        }
        ans+=ms;
 //       cout<<"char(1st state) : "<<c<<" , ans : "<<ans<<"\n";
    }

    cout<<fixed<<setprecision(20)<<(ans/(d)n);

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int mp[26], ct2[26];
int ct[26][26];

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	int n=s.size(), ret=0;
	for (int j=1; j<=n; j++) {
		memset(ct,0,sizeof ct);
		memset(ct2,0,sizeof ct2);

		for (int i=0; i<n; i++)
			ct[s[i]-'a'][s[(i+j)%n]-'a']++;
		for (int i=0; i<n; i++)
			if(ct[s[i]-'a'][s[(i+j)%n]-'a']==1)
				ct2[s[i]-'a']++;
		for (char ch='a'; ch<='z'; ch++)
			mp[ch-'a']=max(mp[ch-'a'],ct2[ch-'a']);
	}
	for (int i=0; i<26; i++)
		ret+=mp[i];
	cout<<setprecision(10)<<fixed<<double(ret)/n<<"\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector <string> V [26];
int toInt(char c)
{
    return (int) (c-'a');
}
int cnt [26];
int main()
{
    string s;
    cin >> s;
    int len = s.size();
    for(int i = 0; i < len; i++)
    {
        cnt[toInt(s[i])]++;
        string t = s.substr(i+1);
        string toAdd = s.substr(0,len-t.size()-1);
        V[toInt(s[i])].push_back(t + toAdd );
    }
    double f = 0;
    for (int i = 0; i < 26; i++)
    {
        if(cnt[i])
        {
            int l = V[i].size();
            double ans = 0;
            for (int j = 0; j < V[i][0].size(); j++)
            {
                int c [26] ;
                for (int x = 0; x < 26; x++) {c[x] = 0;}
                for(int k = 0; k < l; k++)
                {
                    c[toInt(V[i][k][j])]++;
                }
                double t = 0;
                for (int x = 0; x < 26; x++)
                {
                    if (c[x] == 1)
                    {
                        t ++ ;
                    }
                }
                t /= cnt[i];
                ans = max(ans,t);
            }
            f += (ans * cnt[i]);
        }
    }
    cout << fixed << setprecision(12) << f / len;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

const int N=1e5+5;

int m[26][5005][26];

int32_t main()
{
	IOS;
	string s;
	cin>>s;
	int n=s.size();
	s+=s;
	long double ans=0;
	for(int i=0;i<s.size()/2;i++)
	{
		char ch=s[i];
		int ctr=1;
		for(int j=i+1;ctr<=n-1;j++)
		{
			m[ch-'a'][ctr][s[j]-'a']++;
			ctr++;
		}
	}
	for(char ch='a';ch<='z';ch++)
	{
		int max1=0;
		for(int i=1;i<=n-1;i++)
		{
			int cur=0;
			for(int j=0;j<=25;j++)
			{
				cur+=(m[ch-'a'][i][j]==1);
			}
			max1=max(max1, cur);
		}
		ans+=max1;
	}
	ans/=n;
	cout<<fixed<<setprecision(12)<<ans;
	return 0;
}