// Arup Guha
// 11/6/2018
// Solution to 2018 SER D1/D2 Problem: Knockout

import java.util.*;

public class knockout {
	
	// Two dice probabilities (times 36).
	final public static int[] probs = {0,0,1,2,3,4,5,6,5,4,3,2,1};
	
	public static HashSet[] allmasks;
	public static double[][][] dp;
	public static int[][][] path;
	
	public static void main(String[] args) {
		
		// Pre-comp of each subset.
		allmasks = new HashSet[46];
		for (int i=0; i<46; i++) allmasks[i] = new HashSet<Integer>();
		for (int i=0; i<(1<<10); i+=2)
			allmasks[sum(i)].add(i);
		
		// Read the input state.
		Scanner stdin = new Scanner(System.in);
		int mask = getMask(stdin.next());
		int dice = stdin.nextInt();
		dice += stdin.nextInt();
		
		// Store results to subproblems here.
		dp = new double[2][1<<10][13];
		path = new int[2][1<<10][13];
		for (int i=0; i<2; i++) {
			for (int j=0; j<(1<<10); j++) {
				Arrays.fill(dp[i][j], -1);
				Arrays.fill(path[i][j], -1);
			}
		}
		
		// Make both calls.
		double mymin = go(1, mask, dice);
		double mymax = go(0, mask, dice);
		
		// Ta da!
		System.out.printf("%d %.5f\n",getNum(path[1][mask][dice]), mymin);
		System.out.printf("%d %.5f\n",getNum(path[0][mask][dice]), mymax);
	}
	
	// Returns the sum of digits stored in mask.
	public static int sum(int mask) {
		int res = 0;
		for (int i=1; i<10; i++)
			if ((mask & (1<<i)) != 0)
				res += i;
		return res;
	}
	
	// If min == 0, returns the max expected score from (mask,sumroll).
	// If min == 1, returns the min expected score from (mask,sumroll).
	public static double go(int min, int mask, int sumroll) {
		
		// We did this already.
		if (dp[min][mask][sumroll] > -.5) return dp[min][mask][sumroll];
		
		// Go to the new sum.
		int newsum = sum(mask) - sumroll;
		if (newsum < 0) return getNum(mask);
		
		// Means uninitialized.
		double res = -1;
		
		// Other structure would be count down subsets and check in allmasks?
		// Go to all new masks that are reachable from me.
		for (Integer newmask : (HashSet<Integer>)allmasks[newsum] ) {
			if ((newmask & mask) == newmask) {
				
				// This is what we need to add up.
				double tmp = 0;
				for (int nextRoll=2; nextRoll<=12; nextRoll++) {
					tmp += 1.0/36*probs[nextRoll]*go(min, newmask, nextRoll);
				}
				
				// Assign first.
				if (res == -1 || (min == 0 && tmp > res) || (min == 1 && tmp < res)) {
					res = tmp;
					path[min][mask][sumroll] = mask - newmask;
				}
			}
		}
		
		// Return end state (no recursion).
		if (res < 0) return dp[min][mask][sumroll] = getNum(mask);
		
		// Store and return.
		return dp[min][mask][sumroll] = res;
	}
	
	// Returns the mask that corresponds to s.
	public static int getMask(String s) {
		int res = 0;
		for (int i=0; i<s.length(); i++)
			res |= (1<<(s.charAt(i)-'0'));
		return res;
	}
	
	// Returns the full integer corresponding to mask.
	public static int getNum(int mask) {
		
		// Special case for my storage.
		if (mask == -1) return -1;
		
		// Normal way to do this.
		int res = 0;
		for (int i=1; i<10; i++)
			if ((mask & (1<<i)) != 0)
				res = 10*res + i;
		return res;
	}
}
