from __future__ import print_function
from sys import stdin
import random
from time import clock

def printf(str, *args):
	print(str % args, end='')

t1= ["" for i in range(5)]
t2= []
t1t2=[]
t2t1=[]

fp1=open("T1data.txt", 'w')
fp2=open("pointer_result.txt", 'w');
fp3=open("notpoint_result.txt", 'w');

printf("\ncreated a T1 : SAVE T1data.txt\n")
for i in range(0, 5):
	for j in range(0, 20000):
		temp=chr(random.randrange(0, 26)%26+65)
		fp1.write(temp)
		t1[i] = t1[i] + temp
	fp1.write("\n")

printf("\nImage of T2\n")
for i in range(0, 3):
	t2.append(stdin.readline().strip("\n"))

printf("\nImage of T2\n")
for i in range(0, 3):
	printf("<%s>\n" % t2[i])

printf("\n POINTER T1 & T2")
printf("\n    SAVE pointer_result.txt\n")
start = clock()
for g in range(0, 100):
	for j in range(0, 3):
		for i in range(0, 5):
			t1t2.append(t1[i] + t2[j])
end = clock()

for i in range(0, 15):
	fp2.write("%s\n" % t1t2[i])
printf("Execution time : %.3f(ms)\n", (end-start)*1000.0)

printf("\n NOT POINTER T1 & T2")
printf("\n    SAVE notpointer_result.txt\n")
start = clock()
for g in range(0, 100):
	for j in range(0, 3):
		for i in range(0, 5):
			for l in range(0, 20001):
				try:
					if t1[i][l] == "\000":
						break;
				except IndexError:
					break;
			t1t2.append(t1[i] + t2[j])
end = clock()

for i in range(0, 15):
	fp3.write("%s\n" % t1t2[i])
printf("Execution time : %.3f(ms)\n", (end-start)*1000.0)
fp1.close()
fp2.close()
fp3.close()
stdin.readline()