#include int main(){ while(1){ int n, m, p; int i, x; int sum = 0, win = 0; scanf("%d%d%d", &n, &m, &p); if(n == 0) break; m--; for(i=0; i