def RGS_generalized(m):
 d = zeros((m + 1))
 for i in range(0, (m + 1)):
  d[(0, i)] = 1
 for i in range(1, (m + 1)):
  for j in range(m):
   if (j <= (m - i)):
    d[(i, j)] = ((j * d[((i - 1), j)]) + d[((i - 1), (j + 1))])
   else:
    d[(i, j)] = 0
 return d

def RGS_generalized ( m ) : d = zeros ( ( m + 1 ) ) for i in range ( 0 , ( m + 1 ) ) : d [ ( 0 , i ) ] = 1 for i in range ( 1 , ( m + 1 ) ) : for j in range ( m ) : if ( j <= ( m - i ) ) : d [ ( i , j ) ] = ( ( j * d [ ( ( i - 1 ) , j ) ] ) + d [ ( ( i - 1 ) , ( j + 1 ) ) ] ) else : d [ ( i , j ) ] = 0 return d
computes the m + 1 generalized unrestricted growth strings and returns them as rows in matrix .