#!/usr/bin/env python
#coding:utf-8
#1. 输入文件名和数字n，读取文件的前n行

import os

filename = raw_input('input filename: ')
line = int(raw_input('input readline: '))

if os.path.isfile(filename):
    # 第一种
    with open(filename) as f:
        while line > 0:
            for i in f.readline().split('\n'):
                print i
            line -= 1

    # 第二种
    # with open(filename) as f:
    #     for i in f.readlines()[0:line]:
    #         print i

else:
    print 'Eroor! %s  is not exists.' % filename