Nitika was once reading a history book and wanted to analyze it. So she asked her brother to create a list of names of the various famous personalities in the book. Her brother gave Nitika the list. Nitika was furious when she saw the list. The names of the people were not properly formatted. She doesn't like this and would like to properly format it.
A name can have at most three parts: first name, middle name and last name. It will have at least one part. The last name is always present. The rules of formatting a name are very simple:

- Only the first letter of each part of the name should be capital.
- All the parts of the name except the last part should be represented by only two characters. The first character should be the first letter of the part and should be capitalized. The second character should be ".".

Let us look at some examples of formatting according to these rules:
- gandhi -> Gandhi

- mahatma gandhI -> M. Gandhi 
- Mohndas KaramChand ganDhi -> M. K. Gandhi 

-----Input-----
The first line of the input contains an integer T denoting the number of test cases.
The only line of each test case contains the space separated parts of the name.

-----Output-----
For each case, output the properly formatted name.

-----Constraints-----
- 1 ≤ T ≤ 100
- 2 ≤ Length of each part of the name ≤ 10
- Each part of the name contains the letters from lower and upper case English alphabets (i.e. from 'a' to 'z', or 'A' to 'Z')

-----Subtasks-----
Subtask #1 (40 points)
- There is exactly one part in the name.

Subtask #2 (60 points)
- Original constraints.

-----Example-----
Input:
3
gandhi
mahatma gandhI
Mohndas KaramChand gandhi

Output:
Gandhi 
M. Gandhi 
M. K. Gandhi 

-----Explanation-----
The examples are already explained in the problem statement.

Difficulty: EASY
Tags: String algorithms

Data structures

Implementation
Skill types: Data structures

Starter code:

Solutions:
for i in range(int(input())):
	l = list(input().split())
	tot = ''
	if len(l) == 1:
		for j in l:
			print(j.capitalize())
	elif len(l) == 2:
		j = l[0]
		tot += j[0].capitalize() + '. '
		tot += l[1].capitalize()
	elif len(l) == 3:
		j = l[0]
		k = l[1]
		tot += j[0].capitalize() + '. '
		tot += k[0].capitalize() + '. '
		tot += l[2].capitalize()
	print(tot)


t = int(input())
for ni in range(t):
	s = input().split()
	if len(s) == 1:
		a = s[0]
		print(a.capitalize())
	else:
		for i in range(len(s) - 1):
			a = s[i][0].capitalize() + '.'
			print(a, end=' ')
		print(s[-1].capitalize())


t = int(input())
A = 0
for i in range(t):
	s = input().lower()
	c = 0
	e = ''
	for i in range(len(s)):
		if s[i] == ' ':
			c = c + 1
	for i in range(len(s)):
		if c == 0:
			print(s[0].upper() + s[1:])
			break
		elif c == 1:
			if s[i] == ' ':
				print(s[0].upper() + '.' + ' ' + s[i + 1].upper() + s[i + 2:])
				break
		elif c == 2:
			if s[i] == ' ':
				A = i
				f = s[i + 1].upper()
				e = e + f
	if c == 2:
		print(s[0].upper() + '.' + ' ' + e[0] + '.' + ' ' + e[1] + s[A + 2:])


t = int(input())
for _ in range(t):
	s = input()
	names = s.split()
	res = []
	if len(names) >= 2:
		firstname = names[0][0].upper() + '.'
		res.append(firstname)
	if len(names) == 3:
		secondname = names[1][0].upper() + '.'
		res.append(secondname)
	lastname = names[-1].lower()
	lastname = lastname[0].upper() + lastname[1:]
	res.append(lastname)
	print(' '.join(res).strip())


for i in range(int(input())):
	list1 = list(map(str, input().split()))
	if len(list1) == 1:
		answer = list1[0][0].upper() + list1[0][1:].lower()
	elif len(list1) == 2:
		answer = list1[0][0].upper() + '. ' + list1[1][0].upper() + list1[1][1:].lower()
	else:
		answer = list1[0][0].upper() + '. ' + list1[1][0].upper() + '. ' + list1[2][0].upper() + list1[2][1:].lower()
	print(answer)


n = int(input())
for i in range(0, n):
	s = input().split(' ')
	n = len(s)
	m = 0
	k = ''
	if n == 1:
		print(s[0].capitalize())
	else:
		for j in range(n - 1):
			k += s[j][0].capitalize() + '. '
		print(k + s[n - 1].capitalize())


for _ in range(int(input())):
	name = input().split()
	if len(name) == 3:
		print(f'{name[0][0].upper()}. {name[1][0].upper()}. {name[2].title()}')
	elif len(name) == 2:
		print(f'{name[0][0].upper()}. {name[1].title()}')
	else:
		print(name[0].title())


for _ in range(int(input())):
	Name = input().split()
	if len(Name) == 1:
		print(Name[0].capitalize())
	elif len(Name) == 2:
		print(Name[0][0].upper() + '. ' + Name[1].capitalize())
	else:
		print(Name[0][0].upper() + '. ' + Name[1][0].upper() + '. ' + Name[2].capitalize())


t = int(input())
for i in range(t):
	s = str(input())
	li = s.split(' ')
	ans = ''
	for i in li:
		if li.index(i) == len(li) - 1:
			ans = ans + i.title()
		else:
			ans = ans + i[0].upper() + '. '
	print(ans)


t = int(input())
for i in range(t):
	s = input().split()
	st = ''
	if len(s) == 1:
		for char in s:
			print(char.capitalize())
	else:
		t = s[:-1]
		r = s[-1]
		r = r.capitalize()
		new_list = []
		for char in t:
			p = char[0].upper()
			new_list.append(p)
		for char in new_list:
			st += char + '. '
		print(st + r)


T = int(input())
l = []
for i in range(T):
	s = input()
	d = s.split()
	s1 = ''
	if len(d) > 1:
		for i in range(len(d) - 1):
			s1 = s1 + d[i][0].upper() + '.' + ' '
		l.append(s1 + d[-1].capitalize())
	else:
		l.append(d[0].capitalize())
[print(i) for i in l]


s = int(input())
for i in range(0, s):
	name = input().split(' ')
	for i in name:
		if len(name) == 1:
			temp = ''
			temp += name[0][0].capitalize()
			temp += name[0][1:].lower()
			print(temp)
			break
		elif len(name) == 2:
			temp = ''
			temp += name[0][0].capitalize() + '. '
			temp += name[1][0].capitalize()
			temp += name[1][1:].lower()
			print(temp)
			break
		elif len(name) == 3:
			temp = ''
			temp += name[0][0].capitalize() + '. '
			temp += name[1][0].capitalize() + '. '
			temp += name[2][0].capitalize()
			temp += name[2][1:].lower()
			print(temp)
			break


for _ in range(int(input())):
	s = input().split(' ')
	str = ''
	for i in range(len(s) - 1):
		str += s[i][0].upper() + '. '
	print(str + s[len(s) - 1].capitalize())


for _ in range(int(input())):
	a = input().split()
	a[-1] = a[-1].lower().title()
	if len(a) > 1:
		for i in range(0, len(a) - 1):
			a[i] = a[i].replace(a[i], list(a[i])[0]).title()
			a[i] = a[i] + '.'
		for i in a:
			print(i, end=' ')
	else:
		print(a[0], end=' ')
	print()


for _ in range(int(input())):
	name = input().split()
	if len(name) == 3:
		print(name[0][0].upper(), '.', sep='', end=' ')
		print(name[1][0].upper(), '.', sep='', end=' ')
		print(name[2].capitalize())
	elif len(name) == 2:
		print(name[0][0].upper(), '.', sep='', end=' ')
		print(name[1].capitalize())
	else:
		print(name[0].capitalize())


for _ in range(int(input())):
	l = input().split()
	name = ''
	for i in range(len(l)):
		if i == len(l) - 1:
			name += l[i].title()
		else:
			name += l[i][0].upper() + '. '
	print(name)


t = int(input())
for t in range(t):
	s = input().title().split()
	if len(s) == 1:
		print(s[0])
	else:
		i = 0
		while i < len(s) - 1:
			s[i] = s[i][0]
			i = i + 1
		print('. '.join(s))


n = int(input())
for i in range(n):
	s = input()
	t = s.split()
	c = len(t) - 1
	for j in range(c):
		print(t[j][0].capitalize() + '. ', end='')
	temp = t[-1]
	print(temp.capitalize())


for _ in range(int(input())):
	n = input()
	l = list(n.split(' '))
	s = ''
	for i in range(len(l) - 1):
		s1 = l[i].title()
		s += s1[0] + '. '
	s += l[len(l) - 1].title()
	print(s)


for i in range(int(input())):
	name = list(input().split())
	if len(name) == 1:
		print(name[0][0].upper() + name[0][1:].lower())
	elif len(name) == 2:
		print(name[0][0].upper() + '.', name[1][0].upper() + name[1][1:].lower())
	else:
		print(name[0][0].upper() + '.', name[1][0].upper() + '.', name[2][0].upper() + name[2][1:].lower())


for _ in range(int(input())):
	nm = list(map(str, input().split()))
	if len(nm) == 1:
		print(''.join(nm).capitalize())
	elif len(nm) == 2:
		print(nm[0][0].upper() + '.', nm[-1].capitalize())
	else:
		print(nm[0][0].upper() + '.', nm[1][0].upper() + '.', nm[-1].capitalize())


T = int(input())

def main_logic(full_name):
	name_arr = full_name.split(' ')
	output = ''
	length = len(name_arr)
	for i in range(length - 1):
		name_part = name_arr[i]
		output = output + name_part[0].upper() + '. '
	last_name = name_arr[length - 1][0].upper() + name_arr[length - 1][1:].lower()
	output = output + last_name
	return output
for i in range(T):
	name = input()
	formatted_name = main_logic(name)
	print(formatted_name)


t = int(input())
for i in range(t):
	name = list(input().split())
	if len(name) == 1:
		print(name[0].title())
	elif len(name) == 2:
		fn = name[0].title()
		ln = name[1].title()
		ans = fn[0] + '.' + ' ' + ln
		print(ans)
	else:
		fn = name[0].title()
		mn = name[1].title()
		ln = name[2].title()
		ans = fn[0] + '.' + ' ' + mn[0] + '.' + ' ' + ln
		print(ans)


for _ in range(int(input())):
	string = input()
	s = string.title()
	l = s.split(' ')
	if len(l) == 1:
		print(s)
	else:
		ans = []
		for i in range(len(l) - 1):
			char = l[i][0] + '.'
			ans.append(char)
		ans.append(l[-1])
		print(' '.join(ans))


for i in range(int(input())):
	s = input()
	r = ''
	s = ' ' + s
	s1 = s[::-1]
	i = s1.index(' ')
	lisp = len(s) - i - 1
	for i in range(0, lisp):
		if s[i] == ' ' and s[i + 1] != ' ':
			r = r + s[i + 1].upper() + '.' + ' '
	r = r + s[lisp + 1].upper() + s[lisp + 2:].lower()
	print(r)


x = int(input())
for i in range(x):
	y = list(map(str, input().split()))
	j = 0
	while j < len(y) - 1:
		print(y[j][0].capitalize() + '.', end=' ')
		j += 1
	print(y[len(y) - 1].capitalize())


t = int(input())
while t:
	st = input()
	t = t - 1
	l1 = []
	st = st.title()
	l1 = st.split(' ')
	length = len(l1)
	for i in range(0, length - 1):
		print(l1[i][0] + '.', end=' ')
	print(l1[length - 1])


for _ in range(int(input())):
	n = [i for i in input().split()]
	c = ''
	for i in n:
		if i == n[-1]:
			c += i.capitalize()
		else:
			v = i.capitalize()
			c += v[0] + '. '
	print(c)


for _ in range(int(input())):
	s = input().split(' ')
	a = ''
	if len(s) == 1:
		x = s[0].capitalize()
	elif len(s) == 2:
		x = s[0][0].upper() + '. ' + s[1].capitalize()
	else:
		x = s[0][0].upper() + '. ' + s[1][0].upper() + '. ' + s[2].capitalize()
	print(x)


for _ in range(int(input())):
	s = input()
	l = list(s.split())
	if len(l) == 1:
		print(s.capitalize())
	elif len(l) == 2:
		x = l[0]
		m = x[0].capitalize() + '. ' + l[1].capitalize()
		print(m)
	else:
		x = l[0]
		y = l[1]
		m = x[0].capitalize() + '. ' + y[0].capitalize() + '. ' + l[2].capitalize()
		print(m)


for i in range(int(input())):
	n = input().split()
	if len(n) == 1:
		t = n[0]
		print(t.capitalize())
	else:
		for i in n:
			if i != n[-1]:
				t = i.capitalize()
				print(t[0], '.', sep='', end=' ')
			else:
				print(i.capitalize())


for t in range(int(input())):
	s = input().split()
	str = ''
	if len(s) == 1:
		str = s[0].capitalize()
	elif len(s) == 2:
		str = s[0][0].capitalize() + '. ' + s[1].capitalize()
	elif len(s) == 3:
		str = s[0][0].capitalize() + '. ' + s[1][0].capitalize() + '. ' + s[2].capitalize()
	print(str)


for _ in range(int(input())):
	s = input().strip().split()
	pre = s[:-1]
	ans = ''
	for i in pre:
		ans += i[0].upper() + '. '
	ans += s[-1].title()
	print(ans)


for _ in range(int(input())):
	a = list(map(str, input().split(' ')))
	j = 0
	for i in a:
		j += 1
	for i in range(j - 1):
		k = a[i]
		print(k[0].capitalize() + '.', end=' ')
	k = a[j - 1]
	print(k.capitalize())


try:
	for _ in range(int(input())):
		string = input()
		string = string.lower()
		stringd = ''
		t = 0
		for i in range(len(string)):
			t = 0
			if i == 0 or string[i - 1] == ' ':
				stringd = stringd + string[i].capitalize()
				t += 1
				a = i + 1
			if ' ' in string[i:] and t == 1:
				stringd = stringd + '.' + ' '
		for i in string[a:]:
			stringd = stringd + i
		print(stringd)
except:
	pass


def shortname(name):
	namelist = name.split()
	if len(namelist) == 1:
		return namelist[0][0].upper() + str(namelist[0][1:].lower())
	else:
		result = ''
		for (i, item) in enumerate(namelist):
			if i + 1 == len(namelist):
				result += item[0].upper() + item[1:].lower()
			else:
				result += item[0].upper() + '. '
	return result
for _ in range(int(input())):
	print(shortname(input()))


for _ in range(int(input())):
	s = input()
	s = s.lower()
	l = s.split()
	final = ''
	for _ in l[:len(l) - 1]:
		final += _[0].upper()
		final += '. '
	final += l[-1][0].upper() + l[-1][1:]
	print(final)


for _ in range(int(input())):
	a = input()
	a = a.title()
	s = a.split()
	p = ''
	for i in range(len(s) - 1):
		p += s[i][0] + '. '
	p += s[-1]
	print(p)


for i in range(int(input())):
	s = input()
	l = []
	for i in s.split():
		l.append(i)
	k = 0
	l1 = []
	for i in l:
		if k != len(l) - 1:
			i = i.replace(i[:], i[0].capitalize() + '.', 1)
			l1.append(i)
		else:
			i = i.capitalize()
			l1.append(i)
		k += 1
	for i in l1:
		print(i, end=' ')
	print()


def check(s):
	a = list(s.split())
	if len(a) == 1:
		s = s.capitalize()
		return s
	r = ''
	for i in range(len(a) - 1):
		x = a[i].capitalize()
		r += x[0] + '. '
	x = a[-1].capitalize()
	r += x
	return r
n = int(input())
for i in range(n):
	s = input()
	print(check(s))


for _ in range(int(input())):
	s = input()
	Totalspc = s.count(' ')
	newstring = ''
	for i in range(Totalspc):
		newstring += s[0].upper() + '. '
		spc = s.index(' ')
		s = s.replace(s[:spc + 1], '')
	newstring += s[0].upper()
	newstring += s[1:len(s)].lower()
	print(newstring)


for t in range(int(input())):
	x = input().split()
	if len(x) == 1:
		print(x[0].capitalize())
	elif len(x) == 2:
		print(x[0][0].upper() + '. ' + x[1].capitalize())
	elif len(x) == 3:
		print(x[0][0].upper() + '. ' + x[1][0].upper() + '. ' + x[2].capitalize())


T = int(input())
for _ in range(T):
	name = list(map(str, input().split()))
	proper_name = ''
	for i in range(len(name) - 1):
		proper_name = proper_name + name[i][0].upper() + '. '
	proper_name = proper_name + name[-1][0].upper() + name[-1][1:].lower()
	print(proper_name)


t = int(input())

def do():
	s = input()
	c = 0
	v = ' '
	c = s.count(v)
	if c == 0:
		s = s.capitalize()
		print(s)
	elif c == 1:
		f = s.split()[0]
		l = s.split()[1]
		l = l.capitalize()
		print(f[0].capitalize(), '. ', l, sep='')
	elif c == 2:
		f = s.split()[0]
		m = s.split()[1]
		l = s.split()[2]
		l = l.capitalize()
		print(f[0].capitalize(), '. ', m[0].capitalize(), '. ', l, sep='')
	else:
		pass
	return
for i in range(t):
	do()


t = int(input())
for _ in range(t):
	name = input()
	name.lower()
	list_nm = name.split()
	k = len(list_nm)
	if k == 1:
		print(name.title())
	else:
		for i in list_nm[:k - 1]:
			print(i[:1].title() + '.', end=' ')
		print(list_nm[k - 1].title())


for i in range(int(input())):
	s = input()
	s_list = s.split()
	final = ''
	length = len(s_list)
	if length == 1:
		final = s_list[-1].title()
	elif length == 2:
		first_name = s_list[0][0].upper()
		last_name = s_list[1].title()
		final = first_name + '. ' + last_name
	elif length == 3:
		first_name = s_list[0][0].upper()
		second_name = s_list[1][0].upper()
		last_name = s_list[-1].title()
		final = first_name + '. ' + second_name + '. ' + last_name
	print(final)


import re
for tc in range(int(input())):
	n = list(input().title().split())
	if len(n) == 1:
		print(n[0])
	else:
		s = ''
		for i in range(len(n)):
			if i < len(n) - 1:
				s = s + n[i][0] + '. '
			else:
				s = s + n[i]
		print(s)


for i in range(int(input())):
	n = input()
	name = list(n.split())
	if len(name) == 1:
		print(name[0][0].upper() + name[0][1:].lower())
	else:
		for ch in range(len(name) - 1):
			print(name[ch][0].upper() + '.', end=' ')
		print(name[-1][0].upper() + name[-1][1:].lower())


t = int(input())
for i in range(t):
	l = list(input().split())
	if len(l) == 1:
		r = l[0]
		res = r.title()
		print(res)
	elif len(l) == 2:
		fn = l[0].title()
		mn = l[1]
		res = fn[0] + '.' + ' ' + mn.title()
		print(res)
	elif len(l) == 3:
		fn = l[0].title()
		mn = l[1].title()
		ln = l[2].title()
		res = fn[0] + '.' + ' ' + mn[0] + '.' + ' ' + ln
		print(res)


t = int(input())
for i in range(0, t):
	n = input()
	if len(n.split()) == 1:
		print(n[0].upper() + n[1:].lower())
	elif len(n.split()) == 2:
		for i in range(len(n)):
			if n[i] == ' ':
				break
		print(n[0].upper() + '. ' + n[i + 1].upper() + n[i + 2:].lower())
	else:
		k = 0
		for i in range(len(n)):
			if n[i] == ' ':
				k = k + 1
				if k == 1:
					p = i
				if k == 2:
					l = i
					break
		print(n[0].upper() + '. ' + n[p + 1].upper() + '. ' + n[l + 1].upper() + n[l + 2:].lower())


t = int(input())
for i in range(t):
	s = input()
	m = b = c = 0
	n = len(s)
	if s.find(' ') == -1:
		print(s.title())
	else:
		print(s[0].upper() + '.', end=' ')
		for i in range(n):
			if b == 0 and s[i] == ' ':
				m = i
			if s[i] == ' ':
				c = c + 1
				b = i
		if c == 1:
			print(s[b + 1:n].title())
		else:
			print(s[m + 1].upper() + '.', end=' ')
			print(s[b + 1:n].title())


for i in range(int(input())):
	a = str(input())
	names = a.split(' ')
	names = [name.capitalize() for name in names]
	st = ' '
	for j in range(len(names)):
		if j != len(names) - 1:
			st += names[j][0] + '. '
		else:
			st += names[j]
	print(st)


for _ in range(int(input())):
	s = input().split()
	x = ''
	if len(s) == 1:
		x = s[0].capitalize()
	if len(s) == 2:
		x = s[0][0].upper() + '. ' + s[1].capitalize()
	if len(s) == 3:
		x = s[0][0].upper() + '. ' + s[1][0].upper() + '. ' + s[2].capitalize()
	print(x)


for _ in range(int(input())):
	n = input()
	ans = ''
	x = n.title()
	l = x.split(' ')
	if len(l) == 3:
		ans += l[0][0] + '. '
		ans += l[1][0] + '. '
		ans += l[2]
	elif len(l) == 2:
		ans += l[0][0] + '. '
		ans += l[1]
	else:
		ans += l[0]
	print(ans)


for _ in range(int(input())):
	s = input().split()
	for x in range(len(s)):
		if x == len(s) - 1:
			b = s[x]
			print(b[0].upper() + b[1:].lower())
		else:
			b = s[x]
			print(b[0].upper() + '.', end=' ')


t = int(input())
for z in range(t):
	s = input().split()
	if len(s) == 1:
		x = s[0]
		print(x.capitalize())
	else:
		for i in s:
			if i != s[-1]:
				x = i.capitalize()
				print(x[0], '.', sep='', end=' ')
			else:
				print(i.capitalize())


for i in range(int(input())):
	name = list(map(str, input().split()))
	a = []
	for i in range(len(name) - 1):
		a.append(name[i][0].upper() + '. ')
	b = name[len(name) - 1].title()
	print(''.join(a) + b)


for _ in range(int(input())):
	s = input()
	s = s.split()
	n = len(s)
	if n == 1:
		s2 = s[-1][0].upper() + s[-1][1:].lower()
		print(s2)
	else:
		s1 = ''
		s2 = s[-1][0].upper() + s[-1][1:].lower()
		for i in range(n - 1):
			s1 += f'{s[i][0].upper()}. '
		print(s1 + s2)


t = int(input())
for i in range(t):
	l = input().split(' ')
	new = ''
	for j in l:
		if len(l) == 1:
			new = new + l[0][0].capitalize()
			new = new + l[0][1:].lower()
			break
		elif len(l) == 2:
			new = new + l[0][0].capitalize()
			new = new + '. '
			new = new + l[1][0].capitalize()
			new = new + l[1][1:].lower()
			break
		elif len(l) == 3:
			new = new + l[0][0].capitalize()
			new = new + '. '
			new = new + l[1][0].capitalize()
			new = new + '. '
			new = new + l[2][0].capitalize()
			new = new + l[2][1:].lower()
			break
	print(new)


for i in range(int(input())):
	s = input()
	l = s.split(' ')
	if len(l) == 1:
		print(s.capitalize())
	else:
		for i in range(len(l) - 1):
			x = l[i]
			print(x[0].upper() + '.', end=' ')
		print(l[len(l) - 1].capitalize())


for _ in range(int(input())):
	s = input()
	l = s.split(' ')
	if len(l) == 1:
		print(l[0].capitalize())
	elif len(l) == 2:
		print(l[0][0].capitalize(), end='')
		print('. ', end='')
		print(l[1].capitalize())
	else:
		print(l[0][0].capitalize(), end='')
		print('. ', end='')
		print(l[1][0].capitalize(), end='')
		print('. ', end='')
		print(l[2].capitalize())


for _ in range(int(input())):
	s = input().split(' ')
	if len(s) < 2:
		s = s[0][0].upper() + s[0][1:].lower()
		print(s)
	else:
		ans = ''
		for i in range(len(s) - 1):
			ans += s[i][0].upper() + '. '
		ans += s[-1][0].upper() + s[-1][1:].lower()
		print(ans)


for _ in range(int(input())):
	s = input()
	l = s.split()
	l[-1] = l[-1].title()
	for i in range(len(l) - 1):
		l[i] = l[i][0].upper() + '.'
	print(*l)


t = int(input())
for i in range(t):
	name = input()
	n_names = name.split(' ')
	res = ''
	if len(n_names) == 3:
		res += n_names[0][0].upper() + '. ' + n_names[1][0].upper() + '. ' + n_names[2].capitalize()
	elif len(n_names) == 2:
		res += n_names[0][0].upper() + '. ' + n_names[1].capitalize()
	else:
		res += n_names[0].capitalize()
	print(res)


t = int(input())
for i in range(t):
	l = input().split()
	s = ''
	for j in range(len(l)):
		if j == len(l) - 1:
			s += l[j].capitalize()
		else:
			s += l[j][0].upper() + '.' + ' '
	print(s)


t = int(input())
while t:
	arr = []
	S = input().split()
	if len(S) == 1:
		print(S[0].capitalize())
	else:
		for i in range(len(S)):
			arr.append(S[i].capitalize())
		for i in range(len(S) - 1):
			print(arr[i][0] + '.', end=' ')
		print(S[len(S) - 1].capitalize())
	t = t - 1


t = int(input())
while t > 0:
	s = input()
	n = len(s)
	a = ' '
	c = b = m = 0
	d = ''
	if a not in s:
		print(s.title())
	else:
		print(s[0].upper() + '.', end=' ')
		for i in range(n):
			if b == 0 and s[i] == ' ':
				m = i
			if s[i] == ' ':
				c = c + 1
				b = i
		if c == 1:
			print(s[b + 1:n].title())
		else:
			print(s[m + 1].upper() + '.', end=' ')
			print(s[b + 1:n].title())
	t = t - 1


for x in range(int(input())):
	s = [d.lower() for d in input().split()]
	listt = []
	for letter in s:
		string = ''
		for i in range(len(letter)):
			if i == 0:
				string += letter[i].upper()
			else:
				string += letter[i]
		listt.append(string)
	if len(listt) == 1:
		print(listt[0])
	else:
		string = ''
		i = 0
		while i < len(listt) - 1:
			string += listt[i][0]
			string += '. '
			i += 1
		string += listt[-1]
		print(string)


for _ in range(int(input())):
	name = list(map(str, input().split()))
	if len(name) == 1:
		print(name[0].capitalize())
	else:
		Name = ''
		for i in range(len(name) - 1):
			Name += name[i][0].capitalize() + '. '
		Name += name[-1].capitalize()
		print(Name)


t = int(input())
for i in range(t):
	l = list(map(str, input().split()))
	c = 0
	s = ''
	for j in range(len(l)):
		if j == len(l) - 1:
			s += l[j].capitalize()
		else:
			s += l[j][0].upper() + '.' + ' '
	print(s)


t = int(input())
for _ in range(t):
	s = input()
	lis = []
	lisf = []
	x = s.split(' ')
	if len(x) > 1:
		for i in range(len(x)):
			for j in range(len(x[i])):
				if i < len(x) - 1:
					lis.append(x[i][0])
					lis.append('.')
				else:
					lis.append(x[i])
				break
		for i in range(len(lis)):
			for j in range(len(lis[i])):
				m1 = lis[i][0].upper()
				m2 = lis[i][1:].lower()
				m = m1 + m2
				lisf.append(m)
				break
		for i in range(len(lisf)):
			if lisf[i] == '.':
				lisf.insert(i + 1, '0')
		y = ''.join(lisf)
		y1 = y.split('0')
		print(' '.join(y1))
	else:
		y1 = ''.join(x)
		print(y1.capitalize())


for _ in range(int(input())):
	parts = list(input().split())
	for i in range(len(parts) - 1):
		parts[i] = parts[i][0] + '.'
	whole = ' '.join(parts)
	print(whole.title())


t = int(input())
while t:
	name = input()
	name = name.title()
	ls = name.split()
	s = ''
	if len(ls) == 1:
		s = s + ls[0]
	elif len(ls) == 2:
		s = s + ls[0][0] + '. '
		s = s + ls[1]
	else:
		s = s + ls[0][0] + '. '
		s = s + ls[1][0] + '. '
		s = s + ls[2]
	print(s)
	t = t - 1


t = int(input())
for i in range(t):
	s = input().split()
	res = ''
	for i in range(len(s)):
		s[i] = s[i].capitalize()
	if len(s) == 1:
		res = res + s[0]
	elif len(s) == 2:
		k = s[0]
		res = res + k[0] + '. ' + s[1]
	elif len(s) == 3:
		l = s[0]
		m = s[1]
		res = res + l[0] + '. ' + m[0] + '. ' + s[2]
	print(res)


for _ in range(int(input())):
	s = input()
	s = s.lower()
	l = s.split()
	ans = ''
	for i in l[:len(l) - 1]:
		ans += i[0].upper() + '. '
	ans += l[-1][0].upper() + l[-1][1:]
	print(ans)


try:
	for _ in range(int(input())):
		L = input().split(' ')
		if len(L) > 1:
			print(*[L[i][0].upper() + '.' for i in range(len(L) - 1)], end=' ')
		print(L[-1].title())
except:
	pass


for _ in range(int(input())):
	s = list(input().lower().split(' '))
	st = ''
	for i in range(len(s) - 1):
		st += s[i][0].upper() + '. '
	print(st + s[len(s) - 1].capitalize())


t = int(input())
for i in range(t):
	s = []
	s = input().split()
	for j in range(len(s)):
		s[j] = s[j].capitalize()
	for j in range(len(s) - 1):
		print(s[j][0], end='')
		print('.', end=' ')
	print(s[-1])