In this problem the input will consist of a number of lines of English text consisting of the letters of the English alphabet, the punctuation marks ' (apostrophe), . (full stop), , (comma), ; (semicolon), :(colon) and white space characters (blank, newline).
Your task is print the words in the text in lexicographic order (that is, dictionary order). Each word should appear exactly once in your list. You can ignore the case (for instance, "The" and "the" are to be treated as the same word). There should be no uppercase letters in the output.
For example, consider the following candidate for the input text: 
This is a sample piece of text to illustrate this 
problem.

The corresponding output would read as:
a
illustrate
is
of
piece
problem
sample
text
this
to

-----Input format-----
- The first line of input contains a single integer $N$, indicating the number of lines in the input.
- This is followed by $N$ lines of input text.

-----Output format-----
- The first line of output contains a single integer $M$ indicating the number of distinct words in the given text. 
- The next $M$ lines list out these words in lexicographic order.

-----Constraints-----
- $1 \leq N \leq 10000$
- There are at most 80 characters in each line.
- There are at the most 1000 distinct words in the given text.

-----Sample Input-----
2
This is a sample piece of text to illustrate this 
problem. 

-----Sample Output-----
10
a
illustrate
is
of
piece
problem
sample
text
this
to

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
import sys
t = int(input())
x = sys.stdin.readlines()
l = []
for s in x:
	s = s.replace('.', '')
	s = s.replace("'", '')
	s = s.replace(',', '')
	s = s.replace(':', '')
	s = s.replace(';', '')
	lst = [str(i) for i in s.split()]
	for j in lst:
		l.append(j)
m = []
for y in l:
	z = y.lower()
	m.append(z)
n = []
for k in m:
	if k in n:
		continue
	else:
		n.append(k)
print(len(n))
h = sorted(n)
for j in h:
	print(j)


import re
n = int(input())
arr = []
ans = []
for i in range(n):
	temp = input().lower().split()
	for j in temp:
		valids = re.sub('[^a-z]+', '', j)
		arr.append(valids)
while '' in arr:
	arr.remove('')
ans = arr
ans = list(set(list(ans)))
ans.sort()
print(len(ans))
print(*ans, sep='\n')


lst = []
ans = []
punctuations = '!()-[]{};:\'"\\,<>./?@#$%^&*_~'
t = int(input())
for i in range(t):
	str = input()
	s = str.lower()
	no_punct = ''
	for char in s:
		if char not in punctuations:
			no_punct = no_punct + char
	lst.extend(no_punct.split())
for i in lst:
	if i not in ans:
		ans.append(i)
ans.sort()
print(len(ans))
for j in ans:
	print(j)