#!/usr/bin/env python3
import sys
if __name__ == '__main__':
if len(sys.argv) != 4:
print('usage: field infile outfile', file=sys.stderr)
sys.exit(1)
n = int(sys.argv[1])
ifname = sys.argv[2]
ofname = sys.argv[3]
with open(ifname, encoding='utf-8') as fin, \
open(ofname, "w", encoding='utf-8') as fout:
state = 0
for line in fin:
if state == 0:
if line == '\n':
fout.write(line)
else:
assert n > 0
n -= 1
if n > 0:
fout.write(line)
state = 1
else:
state = 2
elif state == 1:
fout.write(line)
if line == '\n':
state = 0
elif state == 2:
if line == '\n':
fout.write(line)
state = 3
elif state == 3:
fout.write(line)
print('ok')