def _finger(eq):
 f = eq.free_symbols
 d = dict(list(zip(f, [([0] * 5) for fi in f])))
 for a in eq.args:
  if a.is_Symbol:
   d[a][0] += 1
  elif a.is_Not:
   d[a.args[0]][1] += 1
  else:
   o = (len(a.args) + sum(((ai.func is Not) for ai in a.args)))
   for ai in a.args:
    if ai.is_Symbol:
     d[ai][2] += 1
     d[ai][(-1)] += o
    else:
     d[ai.args[0]][3] += 1
     d[ai.args[0]][(-1)] += o
 inv = defaultdict(list)
 for (k, v) in ordered(iter(d.items())):
  inv[tuple(v)].append(k)
 return inv

def _finger ( eq ) : f = eq . free_symbols d = dict ( list ( zip ( f , [ ( [ 0 ] * 5 ) for fi in f ] ) ) ) for a in eq . args : if a . is_Symbol : d [ a ] [ 0 ] += 1 elif a . is_Not : d [ a . args [ 0 ] ] [ 1 ] += 1 else : o = ( len ( a . args ) + sum ( ( ( ai . func is Not ) for ai in a . args ) ) ) for ai in a . args : if ai . is_Symbol : d [ ai ] [ 2 ] += 1 d [ ai ] [ ( - 1 ) ] += o else : d [ ai . args [ 0 ] ] [ 3 ] += 1 d [ ai . args [ 0 ] ] [ ( - 1 ) ] += o inv = defaultdict ( list ) for ( k , v ) in ordered ( iter ( d . items ( ) ) ) : inv [ tuple ( v ) ] . append ( k ) return inv
assign a 5-item fingerprint to each symbol in the equation: # of times it appeared as a symbol .