def first_in_class(C, Y=[]):
 n = C.n
 lamda = (-1)
 nu = ([None] * n)
 mu = ([None] * n)
 next_alpha = False
 for alpha in range(1, n):
  for beta in range((lamda + 1)):
   nu[mu[beta]] = None
  for w in Y:
   if (C.table[alpha][C.A_dict[w]] != alpha):
    next_alpha = True
    break
  if next_alpha:
   next_alpha = False
   continue
  mu[0] = alpha
  nu[alpha] = 0
  lamda = 0
  for beta in range(n):
   for x in C.A:
    gamma = C.table[beta][C.A_dict[x]]
    delta = C.table[mu[beta]][C.A_dict[x]]
    if ((gamma is None) or (delta is None)):
     next_alpha = True
     break
    if (nu[delta] is None):
     lamda += 1
     nu[delta] = lamda
     mu[lamda] = delta
    if (nu[delta] < gamma):
     return False
    if (nu[delta] > gamma):
     next_alpha = True
     break
   if next_alpha:
    next_alpha = False
    break
 return True

def first_in_class ( C , Y = [ ] ) : n = C . n lamda = ( - 1 ) nu = ( [ None ] * n ) mu = ( [ None ] * n ) next_alpha = False for alpha in range ( 1 , n ) : for beta in range ( ( lamda + 1 ) ) : nu [ mu [ beta ] ] = None for w in Y : if ( C . table [ alpha ] [ C . A_dict [ w ] ] != alpha ) : next_alpha = True break if next_alpha : next_alpha = False continue mu [ 0 ] = alpha nu [ alpha ] = 0 lamda = 0 for beta in range ( n ) : for x in C . A : gamma = C . table [ beta ] [ C . A_dict [ x ] ] delta = C . table [ mu [ beta ] ] [ C . A_dict [ x ] ] if ( ( gamma is None ) or ( delta is None ) ) : next_alpha = True break if ( nu [ delta ] is None ) : lamda += 1 nu [ delta ] = lamda mu [ lamda ] = delta if ( nu [ delta ] < gamma ) : return False if ( nu [ delta ] > gamma ) : next_alpha = True break if next_alpha : next_alpha = False break return True
checks whether the subgroup h=g1 corresponding to the coset table could possibly be the canonical representative of its conjugacy class .