/**
 * @(#)StringAverage.java
 *
 * StringAverage application
 *
 * @Casey Jenks
 */
 
import java.io.*;
import java.util.*;
 
public class stringave {
	
	//computes the distance between two characters
	public static int distance(char a, char b){
		return Math.abs((int)a - (int)b);
	}
        
    public static void main(String[] args) throws Exception {
    	
    	int i, j, n;
    	Scanner stdin;
    	String[] strWords;
    	Double[] dblAverages;
    	
    	stdin = new Scanner(new File("stringave.in"));
    	    	
    	n = stdin.nextInt();
    	strWords = new String[n];
    	dblAverages = new Double[n];
    	
    	//read in n words
    	for (i = 0; i < n; i++)
    		strWords[i] = stdin.next();
    	    
    	//computer average distances between letters	
    	for (i = 0; i < n; i++){
    		int total = 0;
    		
    		for (j = 0; j < strWords[i].length() - 1; j++)
    			total += distance(strWords[i].charAt(j), strWords[i].charAt(j+1));
    		
    		dblAverages[i] = total / (double)(strWords[i].length()-1);
	   	}   	
	   			   	
	   	//print out the word and its corresponding average.
	   	for (i = 0; i < n; i++){
	   		System.out.println(strWords[i] + " " + dblAverages[i]);
	   	}		
	   	
    }
}
