import sys

inFile = 'keys_G' + sys.argv[1] + '_p1.txt'
outFile = 'keys_G' + sys.argv[1] + '_p2.txt'

fIn = open(inFile, 'r')
fOut = open(outFile, 'w')
tmp = []

for line in fIn:
    tmp.append(line)
tmp.reverse()

for i in range(len(tmp)):
    fOut.write(tmp[i])

fIn.close()
fOut.close()
