/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
#include "bits/stdc++.h"
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define ll long long
#define ld long double
#define gap ' '
#define endl '\n'
#define Mod 1e9+7
/*
*/
vector<char> v;
map<char,int> mp;
pair<int,int> get(string s) {
	int r=0;
	for(char c: s)
	r=r*10+mp[c];
	int d=0,R=r;
	while(r) r/=10,d++; 
	return {R,d};
}
void solve(int testcase) {
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	set<char> chars;
	for(char c: s1) chars.insert(c);
	for(char c: s2) chars.insert(c);
	for(char c: s3) chars.insert(c);
	if(chars.size()>10) {
		cout<<"UNSOLVABLE"<<endl;
		return;
	}
	for(char c: chars) v.push_back(c);
	while(v.size()<10) v.push_back('z'+1);
	do {
		for(int i=0;i<10;i++)
			mp[v[i]]=i;
		
		auto n1=get(s1),n2=get(s2),n3=get(s3);
		if(n1.first+n2.first==n3.first and n1.second==s1.size() and n2.second==s2.size() and n3.second==s3.size()) {
			cout<<n1.first<<endl;
			cout<<n2.first<<endl;
			cout<<n3.first<<endl;
			return;	
		}
	} while(next_permutation(v.begin(),v.end()));
	cout<<"UNSOLVABLE"<<endl;
}

int32_t main() {
	fio
	int T=1;
	//cin>>T;
	for(int t=1;t<=T;t++) solve(t);
	return 0;
}
//tag and rating
#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;

int main(){
    int N,M,K;
    cin>>N>>M>>K;

    set<int> A;
    int Aa[N];
    for(int i=0;i<N;i++) Aa[i]=0;
    for(int i=0;i<K;i++){
        int Ain;
        cin>>Ain;
        Aa[Ain]=1;
        A.insert(Ain);
    }

    if(N>M){
        int c=0;
        for(int i=0;i<M;i++){
            c+=Aa[i];
        }
        if(c>=M){
            cout<<"-1"<<endl;
            return 0;
        }
        for(int i=M;i<N;i++){
            c+=Aa[i];
            c-=Aa[i-M];
            if(c>=M){
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }

    double l=0;
    double r=DBL_MAX/N-1;
    int c=0;
    while(1){
        double m=(l+r)/2;
        double dp[N+1];
        for(int i=0;i<N+1;i++) dp[i]=0;
        double wa=0;
        for(int i=N-1;i>=0;i--){
            if(A.find(i)==A.end()) dp[i]=wa/M+1;
            else dp[i]=m;
            wa+=dp[i];
            if(i+M<=N) wa-=dp[i+M];
            //cout<<i<<","<<wa<<endl;
        }
        //cout<<m<<","<<dp[0]<<endl;
        if(dp[0]<m) r=m;
        else l=m;
        c++;
        if(c>=2000) break;
    }
    printf("%.12f\n",(l+r)/2);

}
