#! /usr/bin/python

import re, sys

d = dict()

def bylen(a,b):
	l = len(a) - len(b)
	a = -1 if a < b else 1
	return (l or a)

def main():
	look = sys.argv[1]
	words = open('/usr/share/dict/words')
	for word in words:
		found = maybe(look, word)
		if found: d[found] = 1
	for k in sorted(d.keys(), cmp=bylen): print k

def maybe(left, rite):
	l = left
	r = rite.strip()
	for c in r:
		t = l.partition(c)
		if not t[1]: return None
		l = t[0] + t[2]
	return r

main()

