1. 

/* @Problem 10903 Rock-Paper-Scissors Tournament
* @Autor Markus Stadler
* @Autor Johannes Müller
*/

import java.io.BufferedWriter;
import java.io.PrintWriter;
import java.util.Scanner;

class RockPaperScissors {
public static void main (String[] args) throws Exception {
BufferedWriter out = new BufferedWriter(new PrintWriter(System.out));
Scanner sc = new Scanner(System.in);
boolean first = true;
while(true) {
int n = sc.nextInt(); //anzahl der spieler
if (n == 0)
break;
int k = sc.nextInt(); //anzahl der runden
k = k*n*(n-1)/2;
float player[][] = new float [n+1][2]; //player[gewinne][spiele]
int p1 = 0;
int p2 = 0;
for (int i = 0; i < k; i++){
p1 = sc.nextInt();
String m1 = sc.next();
p2 = sc.nextInt();
String m2 = sc.next();
if (!m1.equals(m2)){
if (m1.equals("rock")){
if (m2.equals("paper"))
player[p2][0]++;
else
player[p1][0]++;
}
if (m1.equals("paper")){
if (m2.equals("scissors"))
player[p2][0]++;
else
player[p1][0]++;
}
if (m1.equals("scissors")){
if (m2.equals("rock"))
player[p2][0]++;
else
player[p1][0]++;
}
player[p1][1]++;
player[p2][1]++;
}
}
//output
if(first)
first = false;
else
out.write("\n");
for(int p = 1; p <= n; p++){
if(player[p][1] == 0){
out.write("-");
}
else{
player[p][0] = player[p][0] / player[p][1];
String output = String.format( "%.3f" ,player[p][0] );
out.write(output);
}
out.write("\n");
}
}
out.close();
}
}
/*
2 4
1 rock 2 paper
1 scissors 2 paper
1 rock 2 rock
2 rock 1 scissors
2 1
1 rock 2 paper
0
*/