A fair grouping mechanism for tournaments